3
Contributors
2
Replies
23
Views
2 Years
Discussion Span
Last Post by snippsat
0

You use it when you don't know the exact number of arguments.

Simple example ...

def average3(*args):
    """
    don't know the exact number of numeric arguments passed
    prefix * indicates a tuple of variable number of args
    """
    return sum(args)/float(len(args))

print(average3(1, 2, 3, 4, 25))  # 7.0

Edited by vegaseat

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.