Can we have try without catch and which scenario? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can we have try without catch and which scenario?

Can we have try without catch and which scenario?

7th Aug 2019, 10:13 AM
Dexter
Dexter - avatar
6 Answers
+ 1
In any situatiin where you do not want a potential error to crash the program
7th Aug 2019, 10:17 AM
Trigger
Trigger - avatar
+ 1
I used it here at the end to show that if you add more than five items, it raises an error. Though any other situation will work https://code.sololearn.com/c97UM0bMcmqd/?ref=app
7th Aug 2019, 10:34 AM
Trigger
Trigger - avatar
+ 1
In my code, adding an extra item would have thrown an error. Instead of crashing the program, I excecute a block of code in the except statement Except runs code if there was an error instead of crashing the program
7th Aug 2019, 11:18 AM
Trigger
Trigger - avatar
0
If condition not match then it execute try block,if not then it proceed to checkout.
7th Aug 2019, 10:47 AM
Dexter
Dexter - avatar
0
What except does this here ?please explain
7th Aug 2019, 10:49 AM
Dexter
Dexter - avatar
0
Ok thanks
7th Aug 2019, 11:25 AM
Dexter
Dexter - avatar