Trouble with for loop


#1



I am attempting to get this to loop 10 times and print "try again" for each loop that's 10 or below, then on the 11th loop it will print "you lose!" but I cant get it to loop more than once. It is only printing one "try again". Any advice?


chance = [0]
for x in chances:
    if x == 11:
        print "you lose!"
    else:
        print "try again"
        chance[0] += 1


#2

This line does not update so there is only one iteration.


#3

Okay thank you. I wasn't using the for loop right.. derp

i just did this:

loop = [1,2,3,4,5,6,7,8,9,10]
for x in loop:
chance = 0
if chance <= 10:
print "try again"
chance += 1
else:
print "you lose!"


#4

Does this look right to you?


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.