Python Function Mistake: Return Before Print

Day 5 of my coding journey 🚀 A simple mistake, but very common for beginners. Today I made a small mistake in functions...😅 # Functions to add two numbers def add(a, b) return a + b print(add(2, 3)) I expected the output 5, but nothing happened. The print() statement was written after return, so it never executed. Fix ✅ def add(a, b) return a + b print(add(2, 3)) Output: 5 ✅ small mistake, but a good lesson. #Python #AI #MachineLearning

  • No alternative text description for this image

"Reminder: code after "return" never runs in a function!" 👍

Inspiring journey 👏 Growth comes from small consistent efforts 💯 Also learning and sharing—feel free to follow 🚀

Iterative improvement; you got this!

See more comments

To view or add a comment, sign in

Explore content categories