Answers for "why is finally statement used in python"

2

python finally keyword

try:
  x > 3
except:
  print("Something went wrong")
else:
  print("Nothing went wrong")
finally:
  print("The try...except block is finished")
Posted by: Guest on March-05-2020
0

when to use finally python

try:
    run_code1()
except TypeError:
    run_code2()
    return None   # The finally block is run before the method returns
finally:
    other_code()
Posted by: Guest on July-26-2021

Python Answers by Framework

Browse Popular Code Answers by Language