Im making a quick snap game for fun, just learning to code, and I can’t seem to get around this problem.
set1 = ["Horse", "Cow", "Pig", "Goat", "Chicken", "Sheep", "Donkey", "Duck", "Rabbit"]
set2 = ["Horse", "Cow", "Pig", "Goat", "Chicken", "Sheep", "Donkey", "Duck", "Rabbit"]
random.shuffle(set1,random.random)
random.shuffle(set2,random.random)
side1 = int(input("What number would you like to pick from side one?"))
side2 = int(input("What number would you like to pick from side two?"))
s1pick = set1.index(side1)
s2pick = set2.index(side2)
picks = []
I want them to input 2 numbers for side1
and side2
, then store what the corresponding values from set1
and set2
are in s2pick
and s1pick
. But I keep getting this error message:
Traceback (most recent call last):
File "C:/Users/Me/PycharmProjects/nice memes/src/snap.py", line 26, in <module>
s1pick = set1.index(side1)
ValueError: 4 is not in list
Using python 3 on pycharm community edition. Thanks!
set1[side1]
insteadset1.index(side1)
, you want index 4 not value 4 – ᴀʀᴍᴀɴ Mar 24 '16 at 19:47