Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to have unlimited parameters in a function in python

# to pass unlimited parameters add one astors
# this method is for positional arguments
def add(*numbers):
    total = 1
    for number in numbers:
        total += number
    return total

print(add(1, 2, 3, 4, 5)) # add as many as you want

# Output >>> 16
 
PREVIOUS NEXT
Tagged: #unlimited #parameters #function #python
ADD COMMENT
Topic
Name
7+9 =