I am trying to run an old python code made with python 2.7(?) in python 3.3 and I'm stuck on updating the code to run. It keeps telling me "'range' object does not support item assignment" and for the life of I cannot figure it out. The code is for a "50 states trivia" game I found on google.
The error is at the line answer[i] = "%s " % flower[pick[i]].rstrip()
pick = random.sample(range(50), 4)
print("The state flower of %s is:" % state[pick[0]])
answer = range(4)
for i in range(4):
if i == 0:
answer[i] = "%s " % flower[pick[i]].rstrip()
else:
answer[i] = "%s" % flower[pick[i]].rstrip()
BTW, this code is HERE
Use:
to allow modifications