Feb-21-2022, 08:22 PM
I am trying to make it work. The code ask for 3 values and return the highest value.
If input is a string. I want to handle the error with an exception.
If input is a string. I want to handle the error with an exception.
print("Tapez trois valeurs numériques entières:") val1 = int(input("Entrez première valeur: ")) val2 = int(input("Entrez deuxième valeur: ")) val3 = int(input("Entrez troisième valeur: ")) try: if (val1 > val2 and val1 > val3): print(val1) elif (val2 > val3): print(val2) else: print(val3) except: print(merde)
Error:Tapez trois valeurs numériques entières:
Entrez première valeur: > l
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'l' is not defined
>