Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 11
If statement checks a condition. If the condition is true => if block is executed, else block is skipped If the condition is false => else block is executed, if block is skipped We keep statement(s) inside try block when we guess that any unexpected case may occur within those statements (like user giving wrong type of inputs). And if anything unusual happens, that should be handled by except block (like giving error message) If unexpected thing happens => catch block is executed, try block is skipped after the exception If everything goes perfect => try block is fully executed, catch block is skipped
28th Sep 2017, 4:22 PM
Shamima Yasmin
Shamima Yasmin - avatar