Created
September 24, 2020 05:42
-
-
Save codetombomb/5ae0e515688876f0a87dcdb6333af2fe to your computer and use it in GitHub Desktop.
Variable Number of Arguments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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