0
Hi,can someone please help me what's wrong with this python code ? I keep getting the same loop.
name = "" while len(name) <= 12: name = input("what is your name? ") if len(name) > 12: print("Name can be max 12 characters long.Try again") elif len(name) < 6: print("Name must be min 6 characters long.Try again") else: print("Name is ok")
5 Answers
+ 6
Sushobhan Sengupta because you can only input your answer once here on SoloLearn yes you need break
name = ""
while len(name) <= 12:
name = input("what is your name? ")
if len(name) > 12:
print("Name can be max 12 characters long.Try again")
break
elif len(name) < 6:
print("Name must be min 6 characters long.Try again")
break
else:
print(f"Name is ok {name}")
break
+ 1
I don't see anyway to break out of while loop?
+ 1
Sushobhan Sengupta What are the expected inputs and outputs ,any example?
0
Hi Abhay, I'm a beginner..can you help me out ?
0
Just type in a name as input and if it is it's length is larger than 12 then show that "Name can be max 12 characters long.Try again" and you have type your name again.And if it is it's length is smaller than 6 then show that "Name must be min 6 characters long.Try again" and you have type your name again. and if the length of your name is between 6 and 12 then it will show "Name is ok".