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
  • 7

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,149
  • 1
  • 13
  • 21
kederrac
  • 15,932
  • 5
  • 29
  • 52
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
  • 308
  • 1
  • 8