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

0 Upvotes

17 comments sorted by

View all comments

-7

u/ninhaomah 13d ago

Use normal language.

Example : I want McDonald's breakfast. If I didn't specify the drink , would it DEFAULT to hot coffee ?

2

u/csabinho 13d ago

It's rather "I want a McDonalds burger: if I didn't specify my extras, it would be prepared with the default ingredients." And your extras are in a data structure that is empty by default.

3

u/atarivcs 13d ago

This isn't a good example, because if the order-taker is doing their job properly, they will certainly ask what drink you want.

Even if they say "Do you want coffee to drink?", that is still asking.

1

u/LeonardUnger 13d ago

The function is asking, as it's checking for the presence of an argument.