A simple try and except code that doesnt work | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

A simple try and except code that doesnt work

The input should only be a number, i intentionally typed in letters to get ”wrong” but got error instead. https://code.sololearn.com/caa6opwbXkS2/?ref=app

14th Feb 2022, 9:31 PM
Lenoname
3 Answers
+ 4
Place any code statements that might raise or throw an exception in a try block. try: x = int(input("simple input")) except: print("wrong")
14th Feb 2022, 9:34 PM
SoloProg
SoloProg - avatar
+ 3
Lenoname except block only handle those things which are written inside try block.
15th Feb 2022, 2:26 AM
A͢J
A͢J - avatar
+ 1
A͢J i got rid of the first print, works fine now
15th Feb 2022, 10:44 AM
Lenoname