- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVarArgsParameters.py
More file actions
Latest commit
21 lines (13 loc) · 474 Bytes
/
Copy pathVarArgsParameters.py
File metadata and controls
21 lines (13 loc) · 474 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'''
Sometimes you may want to define a function that can take any number of
parameters, i.e variable number of arguments, this can be achieved by
using the stars.
'''
deftotal(a=5, *numbers, **phonebook):
print('a', a)
# Iterate through all items in a tuple
forsingle_iteminnumbers:
print('single_item', single_item)
forfirst_part, second_partinphonebook.items():
print(first_part, second_part)
total(10, 1, 2, 3, Jack=1123, John=2231, Inge=1560)