I’m trying to create a short car race “game” and I’m trying to make loop until the player types quit.
The loop breaks when the player types quit then y and this works great.
The thing I can’t get to work is when the players types quit then n (no), the loop still breaks instead of going back to input("> ").lower()
also, sorry if my coding is messy - I legit started doing this yesterday.
Thanks for the help!
My code:
`print(‘Welcome to car racing, type /help for a list of commands’)
command = “”
while command != “quit”:
command = input(“> “).lower()
if command == “start”:
print(‘Car started, ready to race!’)
elif command == “stop”:
print(‘Car stopped, rest easy.’)
elif command == “quit”:
quit = input(””"Are you sure? Y/N
“”“).lower()
if quit == ‘y’:
print(‘quitting…’)
elif command == “/help”:
print(”“”
Start - to start the car
Stop - to stop the car
Quit - to quit the game
“”")
else:
print(“Sorry, I did not understand that.”) `