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"

my first function with argument

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.

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

4 Answers

Jaxon Gonzales
Jaxon Gonzales
3,562 Points

Hey!

All your code is perfect except for one part. The number of times you multiply Hi should be by the argument that the user passes in. For example:

print("Hi"*count)

This would instead multiply Hi by the argument that the user passes in.

Hope this helps!

Philip Collins
Philip Collins
13,249 Points
def printer(count):
    print ("Hi "*count)

 printer(3)

Don't get why I'm wrong?

Jaxon Gonzales
Jaxon Gonzales
3,562 Points

Three recommendations:

  1. I would recommend not putting a space between a method like print and the parentheses. This can sometime make your code more confusing.
  2. When you call the printer function in your code it looks like it might have a space before it. If so, that is what is causing the error.
  3. Next time that you ask a question on the forum, it would help to put the error you are getting. This makes the question more clear and specific.

Happy Coding!

hi jaxon and philip!! thank you for the answer. with your answer i am already moving forward. thanks again.

Philip Collins
Philip Collins
13,249 Points

Ok, I'm still getting " Bummer! Try again!" error.

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

 printer(3)

i have removed the spaces, really don't understand what I'm doing wrong here :/

Andreas Petri
Andreas Petri
775 Points

Hmm.... The code looks right but it seems like you have an extra space in front of when you call the printer function. Try removing it and see if that helps :)