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"

Piyush Patel
Piyush Patel
17,253 Points

Unable to solve this

I don't know what is wrong with this code. Can someone please help me?

Thank you very much.

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

2 Answers

Stuart Wright
Stuart Wright
41,120 Points

The print function requires that you wrap parentheses around the string you want to print:

def printer(count):
    print("Hi" * count)
Piyush Patel
Piyush Patel
17,253 Points

Oh, I tried my function in my python shell. It worked, but I didn't realise I'm running Python 2.7.

Thanks though.

Stuart Wright
Stuart Wright
41,120 Points

Ah yes, your code is correct for Python 2.x. All Treehouse courses are Python 3.x so would recommend downloading that for your local system.