This is my code:
name1 = input(userQuestions[0]).lower()
while name1 == "" or not name1.replace(' ','').isalpha():
name1 = input(userQuestions[0]).lower()
The 'userQuestions[ ]' are:
userQuestions = (
"Give me name 1?
",
"Give me name 2?
",
"Give me name 3?
",
)
To use my validation on all 3 questions, how do I put this into a function to make it more efficient instead of repeating a similar statement x3?
The only thing that should change in the function is the name (eg. 'name1' to 'name2', 'name3'), and the userQuestions[ ] (eg. userQuestions[0], ...[1], ...[2]).