# reorder the words in a sentence alphabetically def sentenceAlphabetizer(sentence): words = sentence.split(' ') words.sort() sentence = "" for word in words: sentence += word + " " return sentence.strip() if __name__ == '__main__': print sentenceAlphabetizer("basic applepie zoo party") #output: # 'applepie basic party zoo'
A python example based blog that shows how to accomplish python goals and how to correct python errors.
Showing posts with label reorder. Show all posts
Showing posts with label reorder. Show all posts
Tuesday, September 15, 2009
Python - reorder a sentence alphabetically
Subscribe to:
Posts (Atom)