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"

ANDY VAN DEN BOS
ANDY VAN DEN BOS
2,330 Points

Okay you lost me here Kenneth. How do I use (count) and what dose it do?

I cant believe how stumped I am getting on some of theses! WOW buddy! Okay So I get how to def function():, but then how do I make it do what the question is asking me to do? I must have missed a step in the past few lessons.

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

3 Answers

ANDY VAN DEN BOS, you are super close.

Let's look at the instructions for a second:

Write a function named printer. The function should take a single argument, count, 
and should print "Hi " as many times as the count argument. Remember, you 
can multiply a string by an integer.
  1. Function named printer: check
  2. One argument, named count: check
  3. Print "Hi" as many times as count:

Of the three areas, the last one has not been fulfilled.

But why?

Well, we need to print "Hi" as many times as the argument passed to count. With your code, we are not multiplying "Hi" by count, printing the result.

So, let's remove the return keyword and the information that follows.

Now that we've done that, our code should look like the following:

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

Great! Okay, now to fulfill that final requirement, we need to multiply "Hi" by count. What special operator is used for multiplication? Clue: ------> *

After "Hi ", Add *, followed by count.

You should pass!

Let me know if you need any further help!

Never Stop Learning

ANDY VAN DEN BOS
ANDY VAN DEN BOS
2,330 Points

okay i got it to work now.

I started off like this def printer(count): print("Hi ") * count

wrong answer

Then I tried def printer(count): print("Hi ") * (count)

wrong answer

THEN I used

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

and it worked.

So, it took you three tries to solve it?

Well, I guess it's safe to say . . . third time's a charm!

Great job, Andy!

Never Stop Learning

Brian Galassini
Brian Galassini
3,521 Points

Very helpful for us newbies. You are appreciated!

Brian, if ever you need help, feel free to reach out. I'll see what I can do! :)

Never Stop Learning