Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Ryan Sladek
Ryan Sladek
427 Points

How to find the right number of "Hi's"

I think I am having a problem figuring out how to get this code to loop. With the code I have right now my error message says "The number of "Hi's" is not specified.

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

1 Answer

Keifer Joedicker
Keifer Joedicker
5,869 Points

Look at the count argument as an alias for the number that will pass through when the function is called.

Your code is a template for how that function's alias will be manipulated.

The number passed through will be used to return a new string with "Hi" repeated count amount of times.

so the template to follow in order to return the desired outcome is ("Hi" * count):

printer(1)

"Hi " * 1 = "Hi "

printer(2)

"Hi " * 2 = "Hi Hi "

printer(3)

"Hi " * 3 = "Hi Hi Hi "

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

("Hi" * count) = Hi Hi Hi Hi Hi (Does count mean (multiply by 5?))