I'm fairly new to programming and found an exercise that has you make a game. Basically, the program asks for 3 inputs: stop, start, and exit. Start makes the car start, stop makes the car stop, and exit is self explanatory. However, if you input start when the car is already started, it'll tell you the car is started, and so on. However, when I put an input into the terminal, nothing shows up. Can anybody tell me what I'm doing wrong?
Here's my code:
started = False carstate = str(input()) while carstate != "exit": if carstate == "start": if started == False: started == True print("Car has started... ready to go!") if started == True: print("Car has already started") elif carstate == "stop": if started == False: print("Car is already stopped!") if started == True: started == False print("Car is stopped") if carstate == "exit": sys.exit() if carstate == "help": print("Start - starts the car") print("Stop - stops the car") print("Exit - exits the game")
if started == 'False':...str(input()), sinceinput()already returns a string. (You only need to convert type if you're trying to convert the input to int, or float, or some other non-string type)