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"

Paul Je
Paul Je
4,435 Points

Unsure how to format with the right syntax

Not sure how to write this so that count multiplies the string printouts.. tried using brackets in seemingly every combination, any help would be appreciated..

printer.py
count = 10

printer = print("Hi ") * count

3 Answers

What you need to do is put the "* count" inside the "print" statement. The code would look like:

printer = print("Hi " * count)

This should help.

Stephan Olsen
Stephan Olsen
6,650 Points

As Jenny said, you need to place the count inside the parenthesis. Also the challenge asks you to write a function, so you need to define a function named printer and not just a variable -->

def printer(count):
    print("Hi " * count)
count = (the number of times you want to print the "Hi")
def printer(count)
    print("Hi" * count)