Decrease for loop by one
Milter Skyler
matt17 at gmail.com
Wed Jan 23 23:39:10 EST 2013
I'm using this code with Sikuli so thats why I have click()
for x in range(0,10):
decimal_value = random.randint(1,12)
if myList.count(decimal_value) < 1:
egg = 'A%d.png' % (decimal_value)
egg = wait(egg)
click(egg.getCenter().offset(random.randint(-10,10), random.randint(-10,10)))
myList.append(decimal_value)
else:
print x
x-1 = x
print x
I made an array to check if the random integer already exists and then I send it to the else statement at which point I want to decrease x by 1 so that it doesn't count as one of the loops. In other languages this works but it just comes up with the output:
3
2
9
8
10
9
More information about the Python-list
mailing list