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 trialANDY VAN DEN BOS
2,330 PointsOkay 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.
def printer(count):
return (count) * 5
print("Hi ")
3 Answers
MR. 7
24,079 PointsANDY 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.
- Function named
printer
: check - One argument, named
count
: check - 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
MR. 7
24,079 PointsSo, 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
3,521 PointsVery helpful for us newbies. You are appreciated!
MR. 7
24,079 PointsBrian, if ever you need help, feel free to reach out. I'll see what I can do! :)
Never Stop Learning
ANDY VAN DEN BOS
2,330 PointsANDY VAN DEN BOS
2,330 Pointsokay 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.