+ 2

Can we use if statement inside finally statement?

11th Mar 2020, 5:06 AM
Saurabh Sen
Saurabh Sen - avatar
9 Answers
+ 1
Saurabh Sen = is assignment operator and not comparison. Use == instead.
11th Mar 2020, 5:14 AM
XXX
XXX - avatar
+ 6
Saurabh Sen Yes I know. I just want to say in any language we can do same.
11th Mar 2020, 5:26 AM
A͢J
A͢J - avatar
+ 4
Of course. finally statement is just like another block of statements. You can do anything inside them. You can use for/while loops, if/else/elif statements and even another try-except-finally block.
11th Mar 2020, 5:09 AM
XXX
XXX - avatar
9th Jun 2021, 8:42 AM
Tharul Nejana
Tharul Nejana - avatar
+ 3
Saurabh Sen Yes you can do any operation in finally block. Remember finally block always execute https://code.sololearn.com/cXSi99M39v3F/?ref=app
11th Mar 2020, 5:23 AM
A͢J
A͢J - avatar
+ 2
Yes.
11th Mar 2020, 5:11 AM
Sonic
Sonic - avatar
+ 1
@XXX yes dude i forgot that one
11th Mar 2020, 5:17 AM
Saurabh Sen
Saurabh Sen - avatar
+ 1
@Aj Anant tag - python
11th Mar 2020, 5:24 AM
Saurabh Sen
Saurabh Sen - avatar