-1
x = input("What is your name? ")

if len(x) < 3:
  print("minimum 3 characters")
elif len(x) > 50:
  print("maximum 50 characters")
else:
  print("good")

So, when I try to use a while loop I do not manage to repeat the code the correct way, it just prints the answer endlessly and does not ask the question again, how can I do to restart the code properly using a while loop to repeat the entire process?

DialFrost
  • 1,610
  • 1
  • 8
  • 28

1 Answers1

1

The best way would be to use a while True.

while True:
    x = input("What is your name? ")

    if len(x) < 3:
        print("minimum 3 characters")
    elif len(x) > 50:
        print("maximum 50 characters")
    else:
        print("good")
dirrectZ
  • 56
  • 4