So I have a problem with my game, I copy-pasted a part from it here. As you can see, this code shall print Yeah only if the first x elements of the list position are smaller than 7 and if all the rest elements are bigger than 7 and the final element is 0. However as you can see on the example, 0 is not the last element in the list, but I get the printing Yeah. Why is it? Thank you!
position=[3,6,4,2,5,0,10,12,7,8]
where=1
a=1
for i in range(6-where):
if position[i]<7 and position[i]!=0:
pass
else:
a=0
print(a)
for i in range(6-where,-1):
if position[i]>6 and position[-1]==0:
pass
else:
a=0
print(a)
print(position[-1])
if a==1:
print("Yeah")
Aucun commentaire:
Enregistrer un commentaire