Make a program that reads some text and produces as output the distribution of words that start with dierent letters. I recently wrote a program that would count how many times a certain letter would show up, but I am not sure how to look to see at the first letter of each word and count that up. I am stumped. My code for the word counting is below, very basic, new to python.
inn = 'Super man was here.'
place = {}
for r in inn:
place[r] = place.get(r,0) + 1
print place
So the user would do this:
Please type your text: Today is tomorrow.
Would print something out like this:
[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0]
I got this code so far, but not sure how to count it and what not.
s = "We are not going here tonight."
def firstLetter(s):
for item in s.split():
print item[0].upper()
print firstLetter(s)