June 2017
Beginner
320 pages
7h 37m
English
We’re going to do some more practice involving functions and variables to make sure you know them well. This exercise should be straightforward for you to type in, break down, and understand.
However, this exercise is a little different. You won’t be running it. Instead you will import it into Python and run the functions yourself.
ex25.py
1 def break_words(stuff): 2 """This function will break up words for us.""" 3 words = stuff.split(' ') 4 return words 5 6 def sort_words(words): 7 """Sorts the words.""" 8 return sorted(words) 910 def print_first_word(words):11 """Prints the first word after popping it off."""12 word =
Read now
Unlock full access