Skip to content

Commit d4e97b6

Browse files
committed
added dicts
1 parent b452586 commit d4e97b6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

examples/dicts.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
d = {"cat" : 2, "tiger": 0}
2+
d["food"] = 5
3+
d["cheese"] = 7
4+
d["apple"] = "orange"
5+
d[8] = "penguin"
6+
7+
print d
8+
print len(d) # number of keys
9+
for key in d:
10+
print key, d[key]
11+
12+
for key, value in d.items():
13+
print key, value
14+
15+
print "check if food is in d", "food" in d
16+
del d["food"]
17+
print "check if food is in d", "food" in d
18+

0 commit comments

Comments
 (0)