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 trialDerek Gannon
Courses Plus Student 1,140 PointsSingle Argument function help.
def printer(count): return(count) count = ("Hi! ") * 10 print(count)
I have run the above code through PyCharm and in my terminal. Both have produced "Hi!" ten times as indicated. Treehouse is saying it isnt finding the right number of "Hi"s. What am I doing wrong here?
def printer(count):
return (count)
count = ("Hi ") * 10
print(count)
3 Answers
Jennifer Nordell
Treehouse TeacherZachary Kaufman is correct. It wants the print to happen inside the function. Treehouse is going to send your function a number. It could be 7. It could be 9. It could be 38927. We really don't know. And your code has to print out Hi that many times. Here, you're printing out Hi 10 times which is clearly not the number they're sending in. See the count parameter in the function definition? That's going to hold the number they're going to send in and we can use it just like any other variable. However, you're immediately returning it. Take a look at my solution and see what I mean:
def printer(count):
print("Hi" * count)
Here we accept treehouse's number and it gets assigned to count. Then we take "Hi" and print it out count times. However many that is Hope this helps!
Zachary Kaufman
1,463 Pointsdon't return count it is possible the grader received count from the return and quit grading
Derek Gannon
Courses Plus Student 1,140 PointsOutstanding! Thank you both! I was just adding too many steps into the code then.
Zachary Kaufman
1,463 PointsNo problem happy to help :) I make mistakes like that all the time
Jennifer Nordell
Treehouse TeacherDerek Gannon You're quite welcome! Yup Zachary Kaufman! I do too. Actually... anyone who has programmed for more than 15 minutes probably has