0

This is my first time looking into the 'dbm' module as part of an exercise in a book and I can't figure out why I'm getting this error.

import dbm

db = dbm.open('chapt14/dbtest/captions', 'c')
db['cleese.png'] = 'Photo of John Cleese'
db['testeroni.png'] = 'Photo of Cohn Jleese'

for key in db:
    print(key, db[key])
db.close()
Traceback (most recent call last):
  File "/home/individuation/Documents/Code/ThinkPython/chapt14/dbtest/db_test.py", line 7, in <module>
    for key in db:
TypeError: '_gdbm.gdbm' object is not iterable

0 Answers0