#!/usr/bin/env python3
# Modify this file to read the file '/u1/junk/wordlist'
# Hint: remove all references to command-line arguments
from pprint import pprint
path = '/u1/junk/wordlist'
try:
# Open file read only
fd = open(path, 'r')
contents = fd.read()
# Always close every file you open
fd.close()
chars = dict()
# Loop through each character in the file
for c in contents:
# Set the count to chars[c] + 1 (0+1 if there is no record)
chars[c] = chars.get(c, 0) + 1
pprint(chars)
except FileNotFoundError:
print('File not found.')