else finally in the python

technical talkiess
0

 Else …. Finally 


f = open('test.txt')


try:

    f1 = open('does.txt')

except Exception as e:

    print(e)

# ye wala block jaab run hota hai taab except wala run na ho tab agar exccept run hota hai to ye wala block run nahi hoga

else:

    print("else block is run")

    f.close()

# finally block dono condition me run hoga .... try ki case me bhi aur except ke case me bhi.... ye block taab use karte hai apko wo kaam dono case me karna hi karna hai

finally:

    print("Finally block run here")

    f.close()

print("Code finish here ")
Tags

Post a Comment

0Comments

Thanks you for commenting your questions. I will see question and respond you.

Post a Comment (0)