I need to read the letter from a .txt file and print the number of occurrence in txt file. so far i have been able to print the content in one line but having issue with the cou
Here you go. Hopefully your professor will ask you to explain your work.
grades = open('grades.txt').read().split() for grade in sorted(set(grades), key=lambda x: ord(x[0])*3-('+'in x)+('-'in x)): print ('{} students got {}'.format(grades.count(grade), grade))