Python Forum
a little help with a While Loop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
a little help with a While Loop
#3
(Feb-07-2020, 04:25 PM)Hob_78 Wrote: 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 !")
if i give a name which is having length of 7, it is printing welcome msg why ???
Reply


Messages In This Thread
a little help with a While Loop - by Hob_78 - Feb-07-2020, 12:00 PM
RE: a little help with a While Loop - by Hob_78 - Feb-07-2020, 04:25 PM
RE: a little help with a While Loop - by raghava0853 - Feb-11-2020, 05:57 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020