Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def getCharacterFrequencies(myFile):
- # defining my variables
- metalist = []
- character: str
- characterFrequency = []
- # read file and add all characters to a list unless they are a new line character or a space
- characterList = [character for character in open(myFile).read() if character != '\n' if character != ' ']
- # go through each character in my list, count their frequency, and add the count to characterList
- for character in characterList:
- characterFrequency.append(characterList.count(character))
- # return my two list variables, characterList and characterFrequency
- return characterList, characterFrequency
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement