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 trialDomenico Logozzo
3,578 Pointsprinter() missing 1 required positional argument: 'count'
Trying to figure out what I'm missing here. The program ran in the workspace but won't run here? Thanks
def printer(word, count):
return(word) * count
print(printer("Hi ",10))
3 Answers
Chris Freeman
Treehouse Moderator 68,441 PointsThe challenge says "Write a function named printer. The function should take a single argument, count, and should print 'Hi ' as many times as the count argument.
"
count
should be the only parameter specified:
def printer(count):
print("Hi " * count)
Innocent Ngwaru
7,554 Pointsis there anything wrong with my code?
def printer(count):
if count == '6':
print(6 * 'Hi\n')
printer("6")
Chris Freeman
Treehouse Moderator 68,441 PointsIf you're not trying to solve the challenge the code is fine.
While legal code, it will not pass the challenge. It only works for a string value of count
. The challenge wants count
to be an int. The code also adds a newline char after each "Hi
" instead of a space.
Innocent Ngwaru
7,554 PointsThank you Freeman. I was using that code for the challenge, until I got another way through.
Domenico Logozzo
3,578 PointsDomenico Logozzo
3,578 Pointsthanks this works in the shell but also keeps returning Bummer! Didn't find the right number of "Hi"s.
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsRight. The challenge wants the value printed not returned. Answer updated.