Think you know Python? A simple piece of code is stumping learners with an unexpected result. In this challenge, the if condition evaluates to True, yet the output isn't what most expect.
Here's the code:
if True:
pass
else:
print("Hello")
print("World")
Many beginners think "Hello" or nothing prints, but the correct output is "World". Why? Because pass does nothing, the else block is skipped (since the condition is true), and the final print("World") always executes.
This puzzle highlights the importance of indentation and understanding pass in Python. If you got it right, your basics are strong!
Follow Saurabh Chauhan (@SaurabhTechStudio) for daily coding clarity.