[PYTHON] Mixed positional arguments, tuples and dictionaries

def players(job, *args, **kwargs):
    print(job)
    print(args)
    print(kwargs)

players('Brave', 'Warrior', 'Wizard', job1='Monk', job2='Magic swordsman')

Execution result


Brave
('Warrior', 'Wizard')
{'job1': 'Monk', 'job2': 'Magic swordsman'}

"Brave" in job ('Warrior','Wizard') in args are tuple type In kwargs, {'job1':'monk','job2':'magic swordsman'} in dictionary type It is stored.

However,

Recommended Posts

Mixed positional arguments, tuples and dictionaries
How to use lists, tuples, dictionaries, and sets
Python3 | Lists, Tuples, Dictionaries
Python lists, tuples, dictionaries
Positional arguments, keyword arguments, default arguments
Save lists, dictionaries and tuples to external files python
[Introduction to Udemy Python3 + Application] 50. Positional arguments, keyword arguments, and default arguments
Mixed Gaussian distribution and logsumexp
Optional arguments and * args, ** kwargs
Python list and tuples and commas