0

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
2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by MUFC4life
0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.