I've got a question on how to prevent ValueError when inputting only one string as a response to input.
elif choice == "2":
#Input of both name and last name
while True: #Checks for name and last name characters and their length
name, name2 = input("Please tell me your name and last name separated by space ").split()
if name.isalpha() and name2.isalpha() and (len(name) >= 1) and (len(name2) >= 1):
print("--------------------")
print("Nice to meet you! So " + (str(name) + " " + str(name2)) + ", are you ready to begin?")
break
else:
print("ERROR: Choose a name and last name with at least one character and use only letters, please!")
print("--------------------")
I want my program to prevent the input of only one string when asked for two. Similar to checking for name.isaplha() and len(name) >= 1 I want my program to check if there are two strings inserted. If there's only one, I want it to print("ERROR: Choose a name and last name with at least one character and use only letters, please!"), so basically the else: block like for other errors in input.
Thanks!