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!
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
Single 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)
Jennifer NordellTreehouse Teacher
Zachary 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 Kaufman1,463 Points
don't return count it is possible the grader received count from the return and quit grading
Outstanding! Thank you both! I was just adding too many steps into the code then.