Skip to content

Commit 2300756

Browse files
committed
imp variable args added
1 parent 330bd39 commit 2300756

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

variable_args.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# *args- or variable-length arguments allow you to pass a variable number of arguments to a function.
2+
def sum(*args):
3+
total = 0
4+
for num in args:
5+
total += num
6+
return total
7+
8+
result = sum(1,8, 2, 3, 15, 4, 5)
9+
print(f"The sum of the numbers is: {result}")

0 commit comments

Comments
 (0)