Introducing Python for Algorithm Programming
81
def DisplayMulti(ArgCount = 0, *VarArgs):
print('You passed '
+ str(ArgCount) + ' arguments.',
VarArgs)
Notice that the
print()
function displays a string and then the list of arguments.
Because of the way this function is designed, you can type DisplayMulti() and
press Enter to see that you can pass zero arguments. To see multiple arguments at
work, type DisplayMulti(3, 'Hello', 1, True) and press Enter. The output of
('You
passed 3 arguments.', ('Hello', 1, True))
shows that you need not pass
values of any particular type.
Do'stlaringiz bilan baham: |