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 trial

Python Python Basics (2015) Logic in Python Print "hi"

Kayvan Taherpour
Kayvan Taherpour
1,725 Points

Print "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.py
printer(count):
    return count * "Hi "

2 Answers

Hi 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

You 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.

Oh sorry, I didn't even notice that I forgot do use def! Thank you for pointing that out Iain.