I am trying to self learn python and have written a basic program to add sum of 1st n numbers of digits. When I am giving an integer input, it is executing perfectly but on non-integer input, throwing an error NameError: name 'add_it_up' is not defined. My program is written below.
try:
x = int(input('Enter the number upto which you want to add :'))
try:
def add_it_up(x):
sum = 0
for num in range(x + 1):
sum = sum + num
print(sum)
except TypeError:
print("Sorry we are facing a problem")
except ValueError:
print("Please enter an intiger value only")
add_it_up(x)