So I’m trying to learn python better and i’ve been using this website http://www.learnpython.org/
I’m on to functions right now, heres the code
#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()
the output being
e is a benefit of functions!
e is a benefit of functions!
e is a benefit of functions!
r is a benefit of functions!
What am i missing to return the whole scentence
Inside
def build_sentence(info):No need to loop over
infosince you’ll get character by character.Also
In this part:
You are setting up meInfo every time in the loop constantly changing that value.
At the end you are just returning the last value you got from the loop