r/learnpython • • 13d ago

Function without argument

Ive got a function that takes a dictionary as an argument.
Now Id like to program it so when the function is called without any argument, instead of an error message it prints something custom (a dictionary for example).

Any help is appreciated :D

1 Upvotes

17 comments sorted by

View all comments

Show parent comment

1

u/Adrewmc 1d ago edited 1d ago

Fun news. This operation is getting upgraded next Python update. And will soon be as easy as…

print(mydict ?? “Other message”)

??= would assign…
??:= sorry no walrus….yet.

So that might be something you start seeing more often.