Oct-18-2017, 01:30 AM
Newbie, trying to complete this homework assignment. I keep looping through the first name and not moving to the next section. I don't know what I did wrong. Below is my code.
def problem5_2(): import re # first name while True: first = input("Enter the first name:") if first == '': print("This field is required. Please enter your first name.".format(first)) elif first.isalpha(): if len(first) < 2: print("{} is not a valid first name. It is too short. Please enter a valid first name.".format(first)) else: break #last name while True: last = (input("Enter the last name:")) if last == '': print("This field is required. Please enter your last name.".format(last)) elif len(last) <2: print("{} is not a valid last name. It is too short. Please enter a valid last name.".format(last)) else: break # zipcode while True: zip_code = (input("Enter the ZIP code: ")) if zip_code.isdecimal() == False: print("The ZIP code must be numeric. Please enter a valid zip code.") else: break #employee ID: while True: employee_ID = (input("Enter an employee ID:")) if not re.match('(^[A-Z]{2}-[0-9]{4})', employee_ID): print("{} is not a valid ID. Please enter a valide employee ID.".format(employee_ID)) else: break problem5_2