i'm just learning programming and also my native language is not English . so i'm sorry for any vocabulary or grammar issues . i'm trying to create a function that does the try/except scenario but in one function with one argument which in this example is user input . but user input will execute before going into my function so i don't know how to solve it .
i would be appreciated if someone help me with it . thanks in advance.
import time
import sys
def err_handling(command):
try:
x = command
except Exception as e:
print("Wrong Input !!! \n", e)
time.sleep(2)
sys.exit()
else:
return x
y = int(input("please enter a number >> "))
i = err_handling(y)
print(i)
that it .