-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path38_dict_loop.py
More file actions
50 lines (40 loc) · 803 Bytes
/
Copy path38_dict_loop.py
File metadata and controls
50 lines (40 loc) · 803 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# 1. Loop Through Keys
# student = {
# "name": "Shubham",
# "age": 21,
# "course": "MCA"
# }
# for i in student:
# print(i)
#2. Loop Through Values
# student = {
# "name": "Shubham",
# "age": 21,
# "course": "MCA"
# }
# for i in student.values():
# print(i)
#3. Loop Through Keys Using keys()
# student = {
# "name": "Shubham",
# "age": 21,
# "course": "MCA"
# }
# for i in student.keys():
# print(i)
#4. Loop Through Key-Value Pairs Using items()
# student = {
# "name": "Shubham",
# "age": 21,
# "course": "MCA"
# }
# for key, value in student.items():
# print(key, ":", value)
# 5. Print Only Specific Data
student = {
"name": "Shubham",
"age": 21,
"course": "MCA"
}
for key in student:
print(student[key])