Skip to content

Commit 2964b02

Browse files
committed
updated dict_set_solution with more concise way to update dictionary
1 parent 89ee434 commit 2964b02

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Solutions/Session04/dict_set_solution.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,14 @@
7777

7878

7979
# replacing the values in the original dict:
80-
81-
for key, val in d.items():
82-
d[key] = val.count('t')
80+
d.update(a_dict)
8381
print d
8482

83+
# could also do it this way.
84+
#for key, val in d.items():
85+
# d[key] = val.count('t')
86+
#print d
87+
8588
# Create sets s2, s3 and s4 that contain numbers from zero through
8689
# twenty, divisible 2, 3 and 4.
8790

0 commit comments

Comments
 (0)