Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKayvan Taherpour
1,725 PointsPrint "Hi" code challenge
def printer(count):
return count * "Hi "
printer(5)
would the above work? because It does not work when i do it in the code challenge?
printer(count):
return count * "Hi "
2 Answers
Haider Ali
Python Development Techdegree Graduate 24,728 PointsHi there, the code challenge actually asks you to print
'Hi ' not return
it. Get rid of return and wrap print()
around your remaining code and you should be good to go:
def printer(count):
print(count * "Hi ")
Thanks,
Haider
Iain Simmons
Treehouse Moderator 32,305 PointsYou still need the def
keyword to make sure it creates the function, but as Haider Ali points out, you need to use the built-in print
function (if you're using Python 3) to output the result, rather than return it from the function.
Kayvan Taherpour
1,725 PointsThank you.
Haider Ali
Python Development Techdegree Graduate 24,728 PointsOh sorry, I didn't even notice that I forgot do use def
! Thank you for pointing that out Iain.
Kayvan Taherpour
1,725 PointsKayvan Taherpour
1,725 PointsThank you