Skip to content

Instantly share code, notes, and snippets.

@adrianmarkperea
Created October 5, 2019 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adrianmarkperea/46829eb0456a4432c0ebae4424bb56cc to your computer and use it in GitHub Desktop.
Save adrianmarkperea/46829eb0456a4432c0ebae4424bb56cc to your computer and use it in GitHub Desktop.
def sum_all(*args):
result = 0
# args is a list
for arg in args:
result += arg
return result
result = sum_all(1, 2, 3, 4, 5)
print(result) # => 15
# args and kwargs are just arbitrary names
# they can be named whatever you like
def make_pizza(**toppings):
# toppings is a dictionary
print(f'Making pizza with {toppings['main']} and extra {toppings['extra']})
make_pizza(main='bacon', extra='cheese') # => Making pizza with bacon and extra cheese
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment