![]() | ![]() |
It may happen that we do not have knowledge of all arguments needed to be passed into a function. Analogy: Assume that you are writing a program to welcome all new students this semester. In this case, you do not how many will report.
Example
Start IDLE.
Navigate to the File menu and click New Window.
Type the following:
def welcome(*names):
“””This welcome function salutes all students in the names tuple.”””
for name in names:
print(“Welcome”.name)
welcome("Lucy","Richard","Fridah","James")
The output of the program will be:
Welcome Lucy
Welcome Richard
Welcome Fridah
Welcome James