首页 > 代码库 > ex25.py
ex25.py
1 def break_words(stuff): 2 """This is function will break up words for us.""" 3 words = stuff.split(‘ ‘) 4 return words 5 6 def sort_words(words): 7 """sort the words.""" 8 return sorted(words) 9 10 def print_frist_word(words): 11 """prints the frist word after popping it off.""" 12 word = words.pop(0) 13 print (word) 14 15 def print_last_word(words): 16 """Prints the last word after popping it off""" 17 word = words.pop(-1) 18 print (word) 19 20 def sort_sentence(sentence): 21 """Take in a full sentence and returns the sorted words.""" 22 words = break_words(sentence) 23 return sort_words(words) 24 25 def print_frist_and_last(sentence): 26 """prints the frist and last word of the sentence.""" 27 words = break_words(sentence) 28 print_frist_word(words) 29 print_last_word(words) 30 31 def print_frist_and_last_sorted(sentence): 32 """Sorts the words then prints the frist and last one.""" 33 words = sort_sentence(sentence) 34 print_frist_word(words) 35 print_last_word(words)
ex25.py
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。