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"

Arilesere Olaseni
Arilesere Olaseni
417 Points

printer.py

I got stucked

def printer(count): if count == 3: print( "Hi", "Hi", "Hi") count = 3

Please where is the mistake.

printer.py
def printer (count):
    if count == 2:
        print ("Hi","Hi")
        count = 2

4 Answers

Keith Whatling
Keith Whatling
17,759 Points

Is there a space round the hi? if so ammend and it should pass, I tested the code.

Keith Whatling
Keith Whatling
17,759 Points

The clue and answer is in the question.

" Remember, you can multiply a string by an integer."

Kenneth is saying that you can simply multiply "Hi" by the argument (an integer) that you are passing into the function.

so "hi" X some number say 3 will print "HiHiHi"

def printer(arg): 
    print("Hi" * arg)

Its super important to read the question as this what a lot of coding is about, finding the right answer to a question, pulling apart the question will help you write your algorithms and become an amazing coder!

Keep going you are doing great!

Arilesere Olaseni
Arilesere Olaseni
417 Points

Thanks for the assistance but still it didn't work.

def printer (count): if count == 100: print ("Hi " * 100 )

Arilesere Olaseni
Arilesere Olaseni
417 Points

Thanks for the assistance once again. Unfortunately, i don't know what i have been dong wrongly because i'm yet to progress from this point. I think this is my exact code def printer (count): if count == 3: print ("Hi"*3)

Just that it aint working and i even tried it on spyder and not running too.