Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python while loop command gaming code

Command= ""
started = False
while True:
    command = input(">").lower()
    if command== "start":
        if started:
            print(" Car is already started!")
        else:
            started = True
        print("car started")
    elif command=="stop":
        if not started:
            print("Car is already stopped.")
        else:
            started = False
            print("Car stopped")
    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.")
 
PREVIOUS NEXT
Tagged: #python #loop #command #gaming #code
ADD COMMENT
Topic
Name
9+1 =