Updated code to check for floats May not be best method but, works
#! /usr/bin/env python3.8 while True: try: my_name = input('What is your name?: ') if my_name.replace('.','').isdigit(): print(f'{my_name} is a number. Please use letters for a name.') continue else: print(f'It\'s nice to meet you {my_name.title()}') print(f'{my_name.title()}, your name is {len(my_name)} letters long.') break except ValueError as error: print(f'Error: {error}') break while True: try: my_age = input(f'{my_name.title()}, what is your age?: ') if my_age.isalpha(): print(f'{my_name.title()}, {my_age} is not a number.') continue else: age = int(my_age) + 1 print(f'{my_name.title()}, you will be {age} next year.') break except ValueError as error: print(f'Error: {my_name.title()}, please only use whole numbers for age.') continue
Output:What is your name?: 15.3
15.3 is a number. Please use letters for a name.
What is your name?: john
It's nice to meet you John
John, your name is 4 letters long.
John, what is your age?: pop
John, pop is not a number.
John, what is your age?: 15
John, you will be 16 next year.
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags