Whats meaning of these statements? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Whats meaning of these statements?

In python statements are using "try", "except" and c++ or c# using "try" and "catch" statements tharefore i having some doubtz ,please explain which someone who can.

17th Mar 2017, 12:25 PM
Charith Pathum
Charith Pathum - avatar
4 Answers
+ 7
This is called exception handling. You put part of your code which might blow out inside this block, so that the program does not crash. For example: x = input("Enter your age: ") try: age = int(x) except: print("Wrong input!") Now if you didn't use try-except and the user enters 'xxx' as the input, the int() could not convert to a number and the program would crash. If you use try-except, you can continue with the rest of the code eventhough you encountered an error.
17th Mar 2017, 9:02 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 6
try/except is basically the try/catch block in Python.
17th Mar 2017, 1:48 PM
James Flanders
0
exception handling.
17th Mar 2017, 3:15 PM
Ashwin Arya
Ashwin Arya - avatar
0
thanks #kuba i will.. ☺
18th Mar 2017, 7:22 AM
Charith Pathum
Charith Pathum - avatar