Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fd54256

Browse files
authored
Update Dictionaries.py
1 parent 288f937 commit fd54256

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

Dictionaries.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,15 @@
7474
dictNew1 = dict.fromkeys(seq, "not set val") # without default None
7575
print(dictNew1) # {'sex': 'not set val', 'age': 'not set val', 'name': 'not set val'}
7676

77-
78-
79-
80-
81-
82-
83-
84-
85-
86-
87-
88-
89-
90-
77+
# 5) Iterations
78+
students = {"Mike": 19, "Nick": 35, "Shane": 21}
79+
80+
for student in students:
81+
print(f"student: {student}: {students[student]}")
82+
83+
# The same
84+
for student, age in students.items():
85+
print(f"student: {student}, {age}")
86+
87+
# Summ of values
88+
print(sum(students.values()))

0 commit comments

Comments
 (0)