0
In this simple code the program should exit the loop when I type the word quit.
msg = 'Que lugar gostaria de visitar?'
active = True
while active == True:
Here the input is assigned to place and then to word Then check if word equals QUIT and should exit loop with flag to False. But what happens is that the loop keeps going to Else by printing QUIT
place = input(msg)
word = place.upper
if word == 'QUIT':
active = False
else:
print("Então vamos pra "+place+"!")
I don’t know what’s going on, I’ve tried breaking and the same thing happens
upper
is a function, therefore needs to doplace.upper()
– Woss
Tip, you can simply use
while True:
to keep the loop and the commandbreak
to force the output of this instead of working with a single variable for flow control (makes things more obvious).– Giovanni Nunes