所以我想更好地学习python,我一直在使用这个网站http://www.learnpython.org/
我现在就开始工作了,继承了代码
#Add your functions here (before the existing functions)
def list_benefits():
myList = ['More organized code','More readable code','Easier code reuse','Allowing programmers to share and connect code together']
return myList
def build_sentence(info):
addMe = " is a benefit of functions!"
for i in info:
meInfo = i + addMe
return meInfo
def name_the_benefits_of_functions():
list_of_benefits = list_benefits()
for benefit in list_of_benefits:
print build_sentence(benefit)
name_the_benefits_of_functions()
Run Code Online (Sandbox Code Playgroud)
输出是
e是功能的好处!
e是功能的好处!
e是功能的好处!
r是功能的好处!
我错过了什么才能归还整个场景
内 def build_sentence(info):
不需要循环,info因为你将逐个字符地获得.
def build_sentence(info):
addMe = " is a benefit of functions!"
return info + addMe
Run Code Online (Sandbox Code Playgroud)
也在这部分:
for i in info:
meInfo = i + addMe
return meInfo
Run Code Online (Sandbox Code Playgroud)
您每次在循环中不断更改该值时设置meInfo.最后,您只需返回循环中的最后一个值
| 归档时间: |
|
| 查看次数: |
236 次 |
| 最近记录: |