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 trialJonathan Caver
2,222 PointsI have run the following code in the Workspace, and it works when I put a number in for count. What's wrong?
I have run the following code in the Workspace, and it works when I put a number in for count. What's wrong? Thanks.
def printer(count):
return count * "Hi "
print(printer(count))
1 Answer
Jason Anders
Treehouse Moderator 145,860 PointsHey Jonathan,
For the challenge, it just wants you to create the function, which you did (has a couple errors though), but you also called the function, and the challenge did not want that. So first off, you need to delete the function call.
Challenges are very specific and picky. In the function it asked you to create, it wants you to print
and you are using return
.
With that said, print
statements like this need to be enclosed in parenthesis. So, the corrected code for the challenge will be:
def printer(count):
print (count * "Hi ")
To touch on your other point about working in Workspaces when you pass in a number, when you call a function, you have to pass in a value. The count
variable is a 'placeholder' when you create the function, but when you call it, it need an actual value passed in.
So, you really are on the right track. Keep Coding! :)
Zixu Zhao
365 PointsZixu Zhao
365 PointsThis question is a little confusing...actually, I can't understand what this question is asking for. By the way, it seems like the function we defined has nothing to do with the print, is that why we don't need to call the function? If we don't call the function, does that mean we don't use the function at all? Then why we still define it?