I am trying to provide a looping error message to the user for the customerName input so that the user receives an error message if they type anything other than letters aA - zZ,(I don't want to allow the user to input numbers specifically). I would like it to operate similar to the one I used for the customerAge input( which i provided as an example). but I cant seem to figure out the correct code to accomplish this. can anyone provide some insight?
customerName = input('Enter your name: ')
customerAge = int(input('Enter your age: '))
while customerAge <= 15 or customerAge >= 106:
print('Invalid entry')
customerAge = int(input('Enter your age: '))
after reviewing all the answers I received (thanks goes out to all of you for the help). I coded it like this and it appears to be operating correctly.
customer_name = input('Please enter your name: ')
while not customer_name.isalpha():
print('invalid Entry')
customer_name = input('Please enter your name: ')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With