Skip to content

Commit ac70ff5

Browse files
committed
Definite Loops and Dictionaries
1 parent be90cfe commit ac70ff5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Dictionary/main7.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Definite Loops and Dictionaries
2+
3+
# Even though dictionaries are not stored in order,
4+
# we can write a for loop that goes through all the
5+
# entries in a dictionary - actually it goes
6+
# through all of the keys in the dictionary and
7+
# looks up the values
8+
9+
count = {'chuck' : 1, 'fred' : 42, 'jan' : 100}
10+
for key in count:
11+
print(key, count[key])
12+
13+
# Output
14+
15+
# chuck 1
16+
# fred 42
17+
# jan 100

0 commit comments

Comments
 (0)