Functions with variable length arguments

Sometime we might have to pass multiple arguments to a function. In such a case it can be passed as below:

def student(*roll):
    print("Following students cleared the exam:",roll)
       
student(25,26,27,3,4,5)
------------

The output of the above code shall be

Following students cleared the exam: (25, 26, 27, 3, 4, 5)

In the above code, *roll represents variable length argument to function.

Post a Comment

0 Comments