# Program to create acronym from sequence of words on a line # NOTE: a "word" is any sequence of non-blank characters # (user enters line) # Matt Bishop, Apr. 24, 2009 # for ECS 10 Spring 2009 import string; # print first letter of a word # parameter: word, the word # returns: first letter of word def firstletter(word): return word[0]; # Break line into words and print the words one per line # parameter: line, the line to be split up # returns: list of words def getwords(line): # create a list of words listwords = string.split(line, " "); # print them out one per line return listwords; # read a line, break it into words, and print the words # calls: function getwords, firstletter def main(): # get line from user line = raw_input("Type your line: "); # break it into words and print them out words = getwords(line); # initialize acronym string acro = ""; # add first letter of each word in list for i in words: acro = acro + firstletter(i); # announce acronym print acro; main();