def menu(entree='beef', drink='wine'):
print(entree, drink)
menu(entree='beef', drink='coffee')
#上にdessertとかを追加したくなった場合は?
def menu(**kwargs):
print(kwargs)
menu(entree='beef', drink='coffee')
def menu(**kwargs):
for k, v in kwargs.items():
print(k, v)
menu(entree='beef', drink='coffee')
def menu(**kwargs):
for k, v in kwargs.items():
print(k, v)
d = {
'entree': 'beef',
'drink': 'ice coffee',
'dessert': 'ice'
}
menu(**d)
def menu(food, *args, **kwargs):
print(food)
print(args)
print(kwargs)
menu('banana', 'aplle', 'orange', entree='beef', drink='coffee')
beef coffee
{'entree': 'beef', 'drink': 'coffee'}
entree beef
drink coffee
entree beef
drink ice coffee
dessert ice
banana
('aplle', 'orange')
{'entree': 'beef', 'drink': 'coffee'}