Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #http://learnpythonthehardway.org/book/ex25.html
- #very powerful stuff... the code runs but I think there are some issues with python 2.7 and 3.3 here.
- #not sure
- #need to investigate
- def break_words(stuff):
- """This function will break up words for us"""
- words =stuff.split(' ')
- return words
- def sort_words(words):
- """sort the words"""
- return sorted(words)
- def print_first_word(words):
- """print the first word after popping it off"""
- words =words.pop(0)
- print ("word")
- def print_last_word(words):
- """ Prints the last word after popping it off"""
- words = words.pop(-1)
- print ("word")
- def sort_sentence(sentence):
- """Prints the first and last words of the sentence. """
- words = break_words(sentence)
- print_first_word(words)
- print_last_word(words)
- def print_first_and_last_sorted(sentence):
- """Sorts the words then prints the first and last one. """
- words = sort_sentence(sentence)
- print_first_word(words)
- print_last_word(words)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement