Reputation: 127
Im trying to make it so that even after I give the input to the "enter a command", the code will bring me back to the option to give input after displaying what the last input was. For example i would like it to display the "enter a command" prompt continually after previously done. Is there a way to loop the code back without it ever ending?
c1 = "p"
c2 = "d"
c3 = "t"
command = ""
while command != c1:
print("Enter a command: ")
print ("(P)profile / (D)data ")
command = input()
if command == c1 or command == c2:
print ("loading...")
time.sleep(3)
if command == c1:
print ("User: Student")
if command == c2:
print ("ID: 111111111")
time.sleep(1)
print ("Enter a command: ")
print ("(P)profile / (D)data ")
command = input()
Upvotes: 1
Views: 112
Reputation: 626
Put everything in a while True
loop and remove the last 3 lines where you are printing and asking for input (since you're already asking for the input at the beginning)
This should work:
c1 = "p"
c2 = "d"
c3 = "t"
while True:
print("Enter a command: ")
print ("(P)profile / (D)data ")
command = input()
if command == c1 or command == c2:
print ("loading...")
time.sleep(3)
if command == c1:
print ("User: Student")
if command == c2:
print ("ID: 111111111")
time.sleep(1)
Upvotes: 1