MY PYTHON PROGRAMMING JOURNEY ON BLURT- DAY 1

in techhub •  3 years ago 

MY python programming journey on blurt.jpg

Introduction to while loops

command = ""
while command != "quit":
command = input("> ").lower()
if command == "start":
print("Car started...")
elif command == "stop":
print("Car Stopped.")
elif command == "help":
print("""
start - to start the car
stop - to stop the car
quit - to quit
""")
else:
print("Sorry, I don't understand that")


This is basically a car game built with the “while loop” in python programming language.
The program initially starts with an empty command. When the command entered by the user is not quit, the program is ready to accept and process inputs. If the input entered is ‘start’, then the program prints ‘car started’; if the input given is ‘stop’, then the output by the program will be ‘car stopped’; if the input given to the program is ‘quit’, then the program ends and breaks out from the loop. This is basically how the while loop works in python programming language.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE BLURT!