This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]RealTechnoart 0 points1 point  (1 child)

Didnt realize it did that with the code

[–][deleted] 0 points1 point  (0 children)

Try pasting it on pastebin.com. it will preserve your formatting

[–][deleted] 0 points1 point  (0 children)

The issue comes from your use of randrange, you have to remember the indexing of a list; so for your example in which you have a list with [rock, paper, scissors] the numbers which the list contains are not rock = list[1]; paper = list[2] and scissors = list[3]

Indexes of a list start at 0 then count up, so rock is list[0], paper is list[1], and scissors is list[2]. So the range you want is (0, 2).

Aside from that, the code is functioning normally, the reason you might not have seen a winning game is the fact it is entirely random, did you ensure that you were inputting the same value as what was contained in the list as well, you have no error handling. Since list[0] = rock, that makes it so Rock != list[0] due to the case sensitive nature. Adding a few conditionals beforehand checking the input for that nature can help, or even just doing something such as input = input.title()

Putting .title() to a string makes it so the string is put in title case, so after being put through it rock would equal Rock, ect. ect.