Python with practical examples and notes | Python full course

Опубликовано: 16 Май 2026
на канале: Coding with Nirmala
22
4

In this Python video, learn the complete concept of finally and else blocks in exception handling with practical examples and notes.
✅ This video is helpful for beginners and intermediate learners who want to understand how Python handles errors smartly using try, except, else, and finally.


---

🧠 Topics Covered:

What is the finally block in Python?

When and why to use the finally block?

What is the else block in Python try-except?

Practical examples for each concept

Real-time analogies to help you understand better



---

📘 What is the finally block?
The finally block always executes whether an exception occurs or not.
It's commonly used to close files, release resources, or perform clean-up actions.

try:
x = 5 / 0
except ZeroDivisionError:
print("Cannot divide by zero.")
finally:
print("This block always executes.")

📘 What is the else block?
The else block executes only if no exception occurs in the try block.

try:
num = int(input("Enter a number: "))
print("You entered:", num)
except ValueError:
print("That's not a number!")
else:
print("No error occurred.")


---

📍 Real-Time Example: Imagine you're trying to withdraw cash from an ATM:

try: Insert card and enter PIN.

except: If wrong PIN – show error.

else: If correct PIN – dispense cash.

finally: Return the card (always happens).



---

📂 🔗 Useful Links: 📌 My GitHub Repository:
👉 https://github.com/nirma9/Python-full...

📌 My YouTube Channel:
👉    / @codingwithnirmala-nm  


---

🔔 Don’t forget to Like, Share, Comment & Subscribe
📢 #python #exceptionhandling #tryexcept #finallyblock #elseblock #pythonwithnirmala #pythonfullcourse