Frequency of letters in a file

Created by Julien Palard


You should work on this exercise with your own installation of Python, on your computer. Learn how for Mac OSX or Windows.

Your script should be able to open a file named words.txt located in the same folder, compute the frequency of every ascii lowercase letters in its content, and display them according to this format:

b: 0.02
p: 0.02
a: 0.07
o: 0.05
s: 0.09
d: 0.03
i: 0.07
m: 0.02
c: 0.03

I do not care about the order, only the values. No more precision, no less precision, and I want the trailing zeros, meaning 1/2 should be printed 0.50.

There's no corrections yet, hit the `Submit` button to send your code to the correction bot.

Keyboard shortcuts:

  • Ctrl-Enter: Send your code to the correction bot.
  • Escape: Get back to the instructions tab.

See solutions