mardi 1 septembre 2020

How to make it so i can move between home/help/calc/timer while one of them is running?

lets say that while looper == 1; calc() is running then how to get out of it by typing home or timer or help? can i escape a loop and move to another loop?

    import time

looper = 0

def timer():
    timer = int(input())
    while timer > 0:
        time.sleep(1)
        print(timer)
        timer = timer - 1

def calc():
    print(eval(input()))

def help():
    print("Type ~calc~ to open calculator")
    print("Type ~timer~ to open timer")

user = input()

if user == "home":
    print("Back to home.")
    print("Type ~help~ to show list of commands")
    looper = 0
elif user == "calc":
    print("Opened calculator")
    looper = 1
elif user == "timer":
    print("Opened timer")
    looper = 2
elif user == "help":
    looper = 3
else:
     print("Unknown command!")
     looper = 4
while looper == 1:              
    calc()
while looper == 2:   
    timer()
while looper == 3: 
    help()

if i type calc i can like add numbers on one line

Aucun commentaire:

Enregistrer un commentaire