Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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