Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Dolapo Sekoni
PLUS
Dolapo Sekoni
Courses Plus Student 1,431 Points

help with task

kindly assist with printer.py

printer.py
def printer(count):
count * 3
   print("Hi")

3 Answers

Dave StSomeWhere
Dave StSomeWhere
19,822 Points

You should probably review the video again, it appears you're missing some key concepts.

The challenge asks you to: 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.

  1. Write a function name printer - your function is not coded correctly and your first statement in the function is both wrong/unnecessary and not indented.

  2. The function should take a single argument - your function does not take any arguments - double check the video on how functions take arguments

  3. You should print "Hi" as many times as the count argument - this should be part of your print statement

Ask again if still confused after reviewing the vid again, don't think it would help much to just write the code for you and take all the fun out of it :smile:

Dolapo Sekoni
PLUS
Dolapo Sekoni
Courses Plus Student 1,431 Points

thanks Dave,

i reviewed the video again and came up with this. but it still didn't work. from my understanding, the function name is printer and the argument count is in parenthesis. kindly assist

def printer(count): print("Hi " * {}.format(count))

printer(4)

Dave StSomeWhere
Dave StSomeWhere
19,822 Points

OK Dolapo,

Good that you picked up how to specify the argument. Now, their hint that you can multiply the string "Hi" by count will print "HiHiHi" - you don't need or want the format method for this challenge - it is simpler than you're thinking.

Here's what works - hopefully it makes sense - just getting a function to accept an argument and using multiply with a string:

def printer(count):
    print("Hi" * count)
Dolapo Sekoni
PLUS
Dolapo Sekoni
Courses Plus Student 1,431 Points

thanks Dave..... guess i need to think more as a programmer... couldn't believe this is what gave me sleepless night. did it and it works...........

thanks for your time bro