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

Python Python Basics (2015) Logic in Python Print "hi"

FHATUWANI Dondry MUVHANGO
FHATUWANI Dondry MUVHANGO
17,796 Points

printer.py

please help me with this question my first line is "def printer(count):" and i dont know where to go from there

printer.py

4 Answers

Cheo R
Cheo R
37,150 Points

Hello 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).

changed from comment to answer

FHATUWANI Dondry MUVHANGO
FHATUWANI Dondry MUVHANGO
17,796 Points

hi Cheo, i get what you are saying, but i just dont know how i can make it work inside my funtion

The 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

FHATUWANI Dondry MUVHANGO
FHATUWANI Dondry MUVHANGO
17,796 Points

im still confused, i dont know where to go form my first line

FHATUWANI Dondry MUVHANGO
FHATUWANI Dondry MUVHANGO
17,796 Points

ok here is my code:

def printer(count):
....count = 3
....print("hi" * count)
printer(count)

what i'm i not doing right?

You 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.