Word Distribution - #Programmer Zhaoyang Dai#Section...

Info icon This preview shows page 1. Sign up to view the full content.

#Programmer: Zhaoyang Dai #Section: 22C:016:A06 #ID: 00719596 n=raw_input("Please type your text. Type an extra enter when you are done.") #input the first sentence letterList=[] #to get the first letter of every word we input L=[] #the final list L alphabet=["abcdefghijklmnopqrstuvwxyz"] #the alphabet we use for calculate alphabet_capital=["ABCDEFGHIJKLMNOPQRSTUVWXYZ"] #the capitalized alphabet while n: letter=n.split() #to split sentence we input to every single word length=len(letter) #to know how many letters we have in the sentence for l in range (0,length): #l indicates numbers 0 to (length-1) startWith=letter[l][0]
Image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: #to get the first letter of word we input letterList.append(startWith) #concatenate these letter to a list n=raw_input() #input the second sentence for i in range(0,26): #there are 26 letters in the alphabet count1=letterList.count(alphabet[0][i]) #to count the letter from the alphabet list from position 0 to 25 count2=letterList.count(alphabet_capital[0][i]) #to count the letter from the alphabet_capital list from position 0 to 25 count=count1+count2 #add up the two counts, since we calculate these two kinds of letter as a whole L.append(count) #conctenate all counts to a list #output print L...
View Full Document

  • Fall '13
  • MichaelColbert
  • Zhaoyang Dai

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern