I am fairly new to programming and Python and I am struggling with setting up a loop to continue this basic name generator when user input is incorrect. I tried researching this issue but usually find answers using integers and the like and am having difficulty translating examples to execute what I need the program to do. I am not quite sure if my using of the IF, ELSE, and ELIF, statements is even being used correctly. Thanks to anyone who can lend guidance on this topic.
import random
def orcName():
# This is where the program will ask for male or female input from user.
sex = input("What's your sex? ")
# If user chooses Male the program will execute.
if sex == 'Male':
# This is where the list of male first names are stored.
firstNameMale = ['Ughash', 'Spoguk', 'Truigig', 'Wudhagh', 'Wumkbanok', 'Hogug', 'Karrhig', 'Pargu',
'Xokuk', 'Furbog']
# This is where the list of male last names are stored.
lastNameMale = ['Opkagut', 'Zombilge', 'Grushnag', 'Gujarek', 'Igmut', 'Gorgo', 'Filge', 'XorokuShamob',
'Zurgha']
# This is where the random function calls on the lists to assemble the name.
firstName = random.choice(firstNameMale)
lastName = random.choice(lastNameMale)
print('Your name is', firstName, lastName)
break
# If user chooses Female the program will execute.
elif sex == "Female":
# This is where the list of female first names are stored.
firstNameFemale = ['Ughash', 'Spoguk', 'Truigig', 'Wudhagh', 'Wumkbanok', 'Hogug', 'Karrhig', 'Pargu',
'Xokuk',
'Furbog']
# This is where the list of female last names are stored.
lastNameFemale = ['Opkagut', 'Zombilge', 'Grushnag', 'Gujarek', 'Igmut', 'Gorgo', 'Filge', 'XorokuShamob',
'Zurgha']
# This is where the random function calls on the lists to assemble the name.
firstName = random.choice(firstNameFemale)
lastName = random.choice(lastNameFemale)
print('Your name is', firstName, lastName)
break
# If user did not choose Male of Female program will execute.
else:
print('Please choose from Male or Female. Remember capitalization counts!')
break
orcName()