top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Python : How the arbitrary no. of arguments are passed into function ?

+1 vote
352 views
Python : How the arbitrary no. of arguments are passed into function ?
posted Apr 24, 2016 by Vikram Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

While defining a function use * with the last parameter that going to recevie arbitrary no. of parameters.
For example:
num1 = 6
num2 = 9
def main(*collect)
print ("num1 = ", num1, "num2 = ", num2, "collection = ", collect)

main(num1, num2)

Output : num1= 6 , num2 = 9, collection = (6, 9)
This is how function works for arbitrary number of arguments.

answer Apr 24, 2016 by Harshita
...