r/PythonLearning • • Aug 14 '25

Why I didn't getting default value

Post image
5 Upvotes

18 comments sorted by

View all comments

7

u/Dr_Pinestine Aug 14 '25

Today we learn the important difference between zero and null.

If the user types nothing, then input(...) returns an empty string (""), which is then passed as a parameter to hello(...).

Python considers the empty string to be something rather than nothing, so it overrides the default value in the function. If you want it to work as intended, you need to explicitly check for an empty string.