a little help with a While Loop - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: a little help with a While Loop (/thread-24278.html) |
a little help with a While Loop - Hob_78 - Feb-07-2020 A newbie here This code prints "too many tires" at every loop. The goal is to print it at the end of the loop only. (after 3 wrong tries) Can someone help ? x = 1 while x <= 3: name = input("Enter your username: ") if len(name) < 5: print(f"{name} is too short") elif len(name) > 9: print (f"{name} is too long") else: print(f"Welcome {name} !") break x += 1 print("too many tries !") RE: a little help with a While Loop - Hob_78 - Feb-07-2020 I figured it x = 1 while x <= 3: name = input("Enter your username: ") if len(name) < 5: print(f"{name} is too short") elif len(name) > 9: print (f"{name} is too long") else: print(f"Welcome {name} !") break x += 1 else: print("too many tries !") RE: a little help with a While Loop - raghava0853 - Feb-11-2020 (Feb-07-2020, 04:25 PM)Hob_78 Wrote: I figured it |