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"

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,870 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,870 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