Reputation: 7
the program below will not stop printing "quit"
myvar = str("")
while myvar.lower() != "quit":
myvar = raw_input()
print myvar
Thanks
Upvotes: 1
Views: 93
Reputation: 2865
Just change the order.
myvar = raw_input()
while myvar.lower() != "quit":
print myvar
myvar = raw_input()
Upvotes: 2
Reputation:
I would use a while True:
loop and then break it when myvar.lower() == "quit"
:
# Loop continuously
while True:
# Get the input
myvar = raw_input()
# When converted to lowercase, if the input equals "quit"...
if myvar.lower() == "quit":
# ...break the loop
break
# If we get here, then myvar.lower() != "quit"
# So, print the input
print myvar
Upvotes: 3