Skip to content

Instantly share code, notes, and snippets.

@codetombomb
Created September 24, 2020 05:42
Show Gist options
  • Save codetombomb/5ae0e515688876f0a87dcdb6333af2fe to your computer and use it in GitHub Desktop.
Save codetombomb/5ae0e515688876f0a87dcdb6333af2fe to your computer and use it in GitHub Desktop.
Variable Number of Arguments
def tally_nums(*numbers):
total = 0
for n in numbers:
total += n
print(total)
if __name__ == "__main__":
tally_nums(1, 1, 1.3, 4.6)
tally_nums(4, 5, 6, 7, 8, 9)
tally_nums(40, 55, 60, 75, 80, 95)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment