Nov-17-2019, 07:41 PM
OK, so this is from my tutorial and it works fine, but I'm confused by why, so I'm missing something...
command = ""
started = False
while True:
command = input("> ").lower()
if command == "start":
if started:
print("Car already started.")
else:
started = True
print("Car started.")
elif command == "stop":
print("Car stopped.")
elif command == "help":
print("""
start - to start car
stop - to stop car
quit - to quit game
""")
elif command == "quit":
break
else:
print("Sorry, I don't understand that.")I don't understand why it works this way, I thought this would work if I set the variable "started" to True, not False. It is the exact opposite to what I expected.if command == "start":
if started:
print("Car already started.")
else:
started = True
print("Car started.")So, someone inputs "start" (the car), if started (false, so not started), print that it is "already started"... ugh it's giving me a headache
