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"

Jamaru Rodgers
Jamaru Rodgers
3,046 Points

What's the problem here?

I cant figure out what I did wrong. Did I do the wrong operation syntax or am I really missing a line of code somewhere?

printer.py
def printer(count):
    return "Hi " * count

printer(7)
hiply = printer(7)
print(hiply)

1 Answer

Stuart Wright
Stuart Wright
41,119 Points

The problem is that the challenge asked you to make a function that prints something. Instead, you have created a function that returns something, and you then print that outside of the function definition. The end result is the same, but these challenges can be quite picky so you need to follow the instructions exactly.

def printer(count):
    print("Hi " * count)

printer(7)
Jamaru Rodgers
Jamaru Rodgers
3,046 Points

Thanks. The directions always get me cause I'm almost never spot on but like you said, the code still works. But thanks for this!!