'I get a error ""break" can be used only within a loop"
command = ""
while True: # if you use lower() you need to use lowercase letters for upper it's opposite
command = input("> ").lower()
if command == "start":
print("Car started...")
elif command == "stop":
print("Car stopped...") # (dry) don't repeat yourself
elif command == "help":
print("""
start - to start the car
stop - to stop the car
quit - to quit
""")
elif command == "quit":
break
else:
print("Sorry, i don't understand that.")
I want to get rid of this error "break" can be used only within a loop
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
