Day 4

今天还是阅读代码。

def break_words(stuff):
 """This function will break up words for us."""
 words = stuff.split(' ')
 return words
def sort_words(words):
 """Sorts the words."""
 return sorted(words)
def print_first_word(words):
 """Prints the first word after popping it off."""
 word = words.pop(0)
 print word
def print_last_word(words):
 """Prints the last word after popping it off."""
 word = words.pop(-1)
 print word
def sort_sentence(sentence):
 """Takes in a full sentence and returns the sorted words."""
 words = break_words(sentence)
 return sort_words(words)
def print_first_and_last(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)

一堆函数,这是个模版,使用的时候import就好。
如果输入help( ),即得到""" """里面的东西。
明天会将这本书后面几章给学了,再不学感觉这礼拜就过去了。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Start from P132昨天太懒了,我透你吗,打扰我时间的狗贼出门吃饭必涨价! 第8章 函数 使用默认值时,...
    开发猛男阅读 239评论 0 0
  • 现在是2017/8/9 晚上10:51 有好几天没有学习了,真的是最近有点忙呀,每次收拾完都已经10点多了,今天终...
    大象爱着丁小姐阅读 187评论 0 0
  • 第5节 用社群思路区分不同类型的消费者 第6节 巧妙地构建目标客户社群 第7节 免费“雇佣”你的消费者 第8节 社...
    麥麥兜阅读 666评论 0 0
  • 一 words and expressions 1. Language is a fabric that chan...
    Eliot2017阅读 298评论 0 0
  • 我用泪光目送 向日葵远去的背影 她的追求是太阳 和永不回望的眼睛 塞北的沙漠 追不上江南的梅雨 用干涸的唇一叹惋惜...
    但见空山阅读 165评论 2 3