Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. def getCharacterFrequencies(myFile):
  2.  
  3.     # defining my variables
  4.  
  5.     metalist = []
  6.     character: str
  7.     characterFrequency = []
  8.  
  9.     # read file and add all characters to a list unless they are a new line character or a space
  10.  
  11.     characterList = [character for character in open(myFile).read() if character != '\n' if character != ' ']
  12.  
  13.     # go through each character in my list, count their frequency, and add the count to characterList
  14.  
  15.     for character in characterList:
  16.         characterFrequency.append(characterList.count(character))
  17.  
  18.     # return my two list variables, characterList and characterFrequency
  19.  
  20.     return characterList, characterFrequency
  21.  
  22.     pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement