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 trialFHATUWANI Dondry MUVHANGO
17,796 Pointsprinter.py
please help me with this question my first line is "def printer(count):" and i dont know where to go from there
4 Answers
Cheo R
37,150 PointsHello FHATUWANI, you're on the right track. Remember that you can repeat a string by multiplying it with an integer like
print("Hi " * 3)
Hi Hi Hi
Or multiply the string by a variable that contains a number (e.g. 3).
FHATUWANI Dondry MUVHANGO
17,796 Pointsim still confused, i dont know where to go form my first line
FHATUWANI Dondry MUVHANGO
17,796 Pointsok here is my code:
def printer(count):
....count = 3
....print("hi" * count)
printer(count)
what i'm i not doing right?
Jason Anello
Courses Plus Student 94,610 PointsYou don't want to assign a value to count because then you lose whatever number was passed in. Also, the 'h' should be capitalized and a space after Hi
def printer(count):
print("Hi " * count)
You don't have to call the function either. The challenge tester will do that for you.
FHATUWANI Dondry MUVHANGO
17,796 Pointswow it worked. thank you very much
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 Pointschanged from comment to answer
FHATUWANI Dondry MUVHANGO
17,796 PointsFHATUWANI Dondry MUVHANGO
17,796 Pointshi Cheo, i get what you are saying, but i just dont know how i can make it work inside my funtion
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsThe
count
variable is going to be a certain number.So instead of multiplying by 3 as in Cheo's example, you would multiply by
count