+ 3
What the importamce of except statmen
i dont cnow why we use exept
2 Answers
+ 4
You can use except to test the input of the user.
try:
x = int(input())
print(1/x)
except:
print("Please enter a number different from zero.")
If anything go wrong with the code inside the try statement, the code inside the except statement will run. (For example, if the input equals zero or is a string etc.)
+ 3
thank you