Practical, in the second version the program still runs even if a wrong input is givin. The exam is this afternoon and its brute force approach. I cannot use methods that are not in chap 1 to 4. So no append, no max and certainly no enumerate. Try, except was my weakness this is good info.
The bid idea is to use the Try specifically where you know it can return an error, the rest end up in else. Except only return the error message you want to put in.
This option remain the best for the exam:
Edit: i forgot to ask what about sys.exit() and import system? When do i need it?
Thank you sir!
The bid idea is to use the Try specifically where you know it can return an error, the rest end up in else. Except only return the error message you want to put in.
This option remain the best for the exam:
print("Tapez trois valeurs numériques entières:") try: val1 = int(input("Entrez première valeur: ")) val2 = int(input("Entrez deuxième valeur: ")) val3 = int(input("Entrez troisième valeur: ")) except ValueError: print('Enter only whole numbers') else: if val1 > val2 > val3: print('Value 1 is greater ',val1) elif val2 > val3: print('Value 2 is greater,', val2) else: print('Value 3 is greater ',val3)I put 'merde' out of frustration.
Edit: i forgot to ask what about sys.exit() and import system? When do i need it?
Thank you sir!