Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Using *args to pass the variable-length arguments to the function

# Welcome to softhunt.net
def adder(*num):
    sum = 0
    
    for n in num:
        sum = sum + n

    print("Sum:",sum)

adder(5,8)
adder(6,7,8,9)
adder(11,12,13,14,15)
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Using #pass #arguments #function
ADD COMMENT
Topic
Name
2+4 =