Skip to content

Instantly share code, notes, and snippets.

@bergpb
Created December 20, 2018 11:01
Show Gist options
  • Select an option

  • Save bergpb/d4e6dd939ceccb8072c7cb1e0e547c9f to your computer and use it in GitHub Desktop.

Select an option

Save bergpb/d4e6dd939ceccb8072c7cb1e0e547c9f to your computer and use it in GitHub Desktop.
Python args and kwargs usage.
show_name_and_age(*args, **kwargs):
for name in args:
print('My name is: {}'.format(name))
for name in kwargs.keys():
print('{} has {} years old.'.format(name, kwargs[name]))
show_name_and_age('Josh', 'Hannah', Josh=19, Hannah=26)
# out
# My name is: Josh
# My name is: Hannah
# Hannah has 26 years old.
# Josh has 19 years old.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment