#!/usr/bin/env python3
tm = open('./timemachine.txt', 'r')
Dict = {}
for line in tm:
line = line.strip()
line = line.translate('!"#$%&\'()*+-./:;<=>?@[\\]^_`{|}~')
line = line.lower()
List = line.split(' ')
for word in List:
if word in Dict:
count = Dict[word]
count += 1
Dict[word] = count
else:
Dict[word] = 1
for word, count in Dict.iteritems():
print(word + ":" + str(count))
In the program above I'm getting the error -> builtins.AttributeError: 'dict' object has no attribute 'iteritems'
I'm following code that was given to me by the magazine Guru Guide / Coding Academy
Any ideas? Thanks.