Can we call a function from except block in python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can we call a function from except block in python

I have made a function name readFile(name): then calling it from except block when file name is not correct.tell me about this,how to execute this except: print() readFile(name) print() when i run this code both print statement executed but calling fun not,why ?

10th Aug 2017, 11:15 AM
Amit
Amit - avatar
1 Answer
+ 9
functions can be called in except statements, I do it all the time. I recommend testing to make sure the input argument is correct, and that the function itself is working properly with the input.
10th Aug 2017, 11:19 AM
Ahri Fox
Ahri Fox - avatar