0

hi guys,how to show error when a user input the name with number,it is possible solve it without using def function?

28th Jun 2020, 10:46 AM
AC JT
AC JT - avatar
2 odpowiedzi
+ 4
try: name = input('Enter name > ') for n in name: if n.isdigit(): raise ValueError print('Hello ' + name + '!') except ValueError: print('NO NUMBERS')
28th Jun 2020, 10:56 AM
Slick
Slick - avatar
+ 4
Here is a sample that works without try: except: inp = input('enter name: ') res = ''.join([i for i in inp if not i.isdigit()]) print('correct') if len(res) == len(inp) else print('not correct')
28th Jun 2020, 12:50 PM
Lothar
Lothar - avatar