I have written this very simple program in python:
a=input('Enter the grade:')
if int(a)<5:
print('D')
elif 5<=int(a)<10:
print('c')
elif 10<=int(a)<15:
print('B')
elif 15<=int(a)<=20:
print('A')
elif 20<int(a):
print('You idiot !')
else :
print('Write a number idiot !')
And the program will work if the user write a number, but if they write a string the program will give this error:
Traceback (most recent call last):
File "C:\Users\sony\Desktop\Grader.py", line 2, in <module>
if int(a)<5:
ValueError: invalid literal for int() with base 10: 'h'
How can I change the program, so that the users can write anything they want!