Jul-27-2020, 11:58 AM
(This post was last modified: Jul-27-2020, 11:58 AM by neshom_imilas.)
hello!
I am new to coding and I have 0 experience.
I've started learning just yesterday! I was writing something to take a full name and sort out first and last name. but I have a problem.
but if I put less than 6 characters it won't accept and it will go back to the top!
why is that?!what is the difference between these two lines of code!?
Thank you
please help me learn
I am new to coding and I have 0 experience.
I've started learning just yesterday! I was writing something to take a full name and sort out first and last name. but I have a problem.
while True: full_name = input('What is your full name!? ') first_and_last_name = full_name.split(' ') first_name = first_and_last_name[0] number_of_name_segments = len(first_and_last_name) full_name_length = len(full_name) numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] numbers_in_name = False for letters in full_name: if letters in numbers: numbers_in_name = True break if numbers_in_name: print('Names can\'t have numbers in them') if full_name_length < 6: print('Your name is too short.') if full_name_length > 50: print('Your name is too long.') if number_of_name_segments <= 1: print('Please enter your full name.') if number_of_name_segments == 2: last_name = first_and_last_name[-1] middle_name = 'none' break if number_of_name_segments == 3: last_name = first_and_last_name[-1] middle_name = first_and_last_name[1] break if number_of_name_segments > 3: print('Only enter your first and middle and last name.') print(f'Hello {first_name} {middle_name} {last_name} welcome abroad!')this is my code. the problem is when I enter numbers instead of my name the code doesn't go back to the top. it just accepts the numbers as a name!!!
but if I put less than 6 characters it won't accept and it will go back to the top!
why is that?!what is the difference between these two lines of code!?
Thank you

