Write a Python program to check whether a string is numeric.

Write a Python program to check whether a string is numeric.

1
2
3
4
5
6
7
str = 'a123'
#str = '123'
try:
    i = float(str)
except (ValueError, TypeError):
    print('\nNot numeric')
print()

Final output

Leave a Comment