0

Made this example code:

a = input("Insert day: ")
a
if a == "saturday":
    print("Good Saturday!")
elif a == "sunday":
    print("Good Sunday!")
else:
    print("hi")

My goal is to "re-do" the whole thing when it's done so ask for input, wait the input, when input is entered then print, then again ask for input and so on.. So I added something to loop it:

a = input("Insert day: ")
count = 0
while (count < 1):
    a
    if a == "saturday":
        print("Good Saturday!")
    elif a == "sunday":
        print("Good Sunday!")
    else:
        print("hi")

The problem is that this new code loops/spams the print answer, I never really used loop before, as I said i'm trying to get it to ask "Insert day" after it printed the answer and so on, possibly with 1 or 2 seconds delay from print to asking input, how would I do this?

Yukon
  • 57
  • 1
  • 9

2 Answers2

1

To ask for user input again, simply place the first line into the loop as well:

while True:
    a = input("Insert day: ")
    if a == "saturday":
        print("Good Saturday!")
    elif a == "sunday":
        print("Good Sunday!")
    else:
        print("hi")
Michael Kolber
  • 1,309
  • 1
  • 14
  • 23
kederrac
  • 16,819
  • 6
  • 32
  • 55
1
    count = 0
    while (count < 1):
         a = input("Insert day: ")
         if a == "saturday":
             print("Good Saturday!")
         elif a == "sunday":
             print("Good Sunday!")
         else:
             print("hi")

Because you are defining your variable outside the loop, it became infinite.

Vikika
  • 318
  • 1
  • 9