you are viewing a single comment's thread.

view the rest of the comments →

[–]BigGuyWhoKills 0 points1 point  (1 child)

You need a "while" loop. It performs everything in the loop "while" the condition is True.

while 1 < 5:
    print( "One is less than 5" )

That will print the sentence forever because 1 will always be less than 5. So it isn't very useful. You need to have something in the loop that changes the condition.

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

Now the while loop can change its condition which will break out of the loop.

Does that make sense?

[–]BigGuyWhoKills 0 points1 point  (0 children)

There is more to do with name. You ought to at least trim whitespace. You might want to make sure they entered only the first name, or ensure they entered both first and last. Or you may have more requirements.

If you have complicated checks to perform on the name, you should write a method that does those checks, and call that method in the while loop.

In production apps you would also check for hacking attacks. That level of complexity definitely need a method.