Exercise 26 lp2thw - Corrected all errors. Script compiles and runs no issues

This commit is contained in:
Ganome 2021-04-20 00:32:13 +00:00
parent e51066f7be
commit 9b7a30153d

View File

@ -0,0 +1,35 @@
def breakWords(stuff):
"""This function will break up words for us."""
words = stuff.split(' ')
return words
def sortWords(words):
"""Sort words."""
return sorted(words)
def printFirstWord(words):
"""Print first word after popping it off."""
word = words.pop(0)
print(word)
def printLastWord(words):
"""Prints the last word after popping it off."""
word = words.pop(-1)
print(word)
def sortSentence(sentence):
"""Takes in a full sentence and returns the sorted words."""
words = breakWords(sentence)
return sortWords(words)
def printFirstAndLast(sentence):
"""Printe the first and last word of a sentence"""
words = breakWords(sentence)
printFirstWord(words)
printLastWord(words)
def printFirstAndLastSorted(sentence):
"""Sorts the words then prints the first and last one."""
words = sortSentence(sentence)
printFirstWord(words)
printLastWord(words)