I have a while block, and inside it I have decision making blocks including elif blocks. I want that the program exits from the while block when obje_error == 0, but the while block repeats instead.
I suppose that obje_error == 0 when the other conditions are not complete. I removed the elif blocks and it worked, but I want that the all blocks go to work.
You can see the code below:
while (obje_error == 1):
Sen=raw_input("tas mi,kagit mi yoksa makas mi?")
if (Sen != "tas") :
print "Lutfen tas,kagit ya da makas'i secin..."
obje_error=1
elif (Sen != "kagit"):
print "Lutfen tas,kagit ya da makas'i secin..."
obje_error=1
elif Sen != "makas":
print "Lutfen tas,kagit ya da makas'i secin..."
obje_error=1
else:
obje_error=0
Can you tell me what the problem is and what I can do?
Sencan only hold one string, so it'll betasorkagitormakasor something else, so it'll always trigger either the first or the second of the three!=tests. It'll never get to the lastelsestatement. Did you perhaps mean to test for==instead?intests, or a singleifwith multiple conditionsored together. Also, if all you want is an infinite loop to break out of when a condition is satisfied,forwithbreaktends to be cleaner. Could you lay out your requirements for this whole chunk of code, from a higher level?