# 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'
No comments:
Post a Comment