-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay18.py
More file actions
26 lines (17 loc) · 756 Bytes
/
Copy pathDay18.py
File metadata and controls
26 lines (17 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# *args = parameter that will pack all arguments into a tuple
# useful so that a function can accept a varying amount of arguments
def add(*stuff):
added = 0
for i in stuff:
added += i
return added
print(add(1, 2, 3, 4, 5, 6))
# **kwargs = parameter that will pack all arguments into a dictionary
# useful so that a function can accept a varying amount of keyword arguments
def hello(**kwargs):
print("Hello " + kwargs['first'] + "" + kwargs['middle'] + "" + kwargs['last'])
print("Hello " + kwargs['first'] + " " + kwargs['last'])
for key, value in kwargs.items():
# print(value)
print(value, end=" ")
hello(first="prawin", middle="kumar", last='j s ')