Hello, i have to write a piece of code that allows me to open a txt file which then tells me the amount of each letter there is in the document. However i have this code which opens the document but instead of telling me how manu letters it lists the amount of sentences e.g. it lists (Create a lazy list of prime numbers):1 instead of the amount of each letter there is.

Any help would be hughley appreciated.

import sys

textfile =(sys.argv)

a={}

openfile = open('Assignement list.txt')
for c in openfile:
    try:
        a[c]+=1
    except:
        a[c]=1

print a

line 8 change to openfile.read():

Thankyou! Thankyou! Thankyou! I am very stressed at the moment and that has relieved some of it. Thank You

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.