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 trial
alekseibingham
4,491 PointsI completed the challenge but when viewing the "preview" it makes no sence
"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."
My Answer:
def printer(count): print("Hi " * count)
printer(12)
While it is printing "Hi " times the count, if i replace count with 12 as i did, and run the program, it spits out only 5 "HI "s. Why is this? No matter what number I put in there it always prints 5 "Hi "s!
1 Answer
Jaxon Gonzales
3,562 PointsHi Aleksei!
On most code challenges you should not have to call the function. It should just be the code:
def printer(count):
print("Hi"*count)
Also, when you are looking at the preview mode (I'm not 100% sure about this but I think this might be how it works) the website runs your function with a certain argument to see what the output is.
Basically, I would just try getting rid of the line that calls the function.
Hope this helps!
alekseibingham
4,491 Pointsalekseibingham
4,491 Pointssounds great, thanks!