+ 2
I want to add input code to a try-exception code, How do this ?
I want to add something like this my_input = int(input("please enter input: ")) to this: https://code.sololearn.com/cotMyjwiWN09/#py How may I do this ?
3 ответов
+ 11
try:
num = int(input())
print ("I was DONE !")
except:
print("An error occurred")
raise
+ 6
specify which type of error/errors
try:
x = int(input("enter an integer: "))
y = 6 / x
print(y)
except (ZeroDivisionError, ValueError) as e:
print(e)
print("something happened.....")
+ 2
Thanks Hatsy
I think this modified code is more accurate:
https://code.sololearn.com/cjXempf2Xa8D/?ref=app