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"

Emilio Andere
Emilio Andere
495 Points

Python basics

these are the instructions: 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

1 Answer

Hi Emilio,

If your trying to get the solution to this problem. I'll give you a hint.

Write a function named printer. The function should take a single argument, count, This means that in your function declaration,

def printer(): # <- "single argument" - there should be one variable placeholder inside the parenthesis that will hold the value of count 

and should print "Hi " as many times as the count argument. Remember, you can multiply a string by an integer. This means you are going to use print() and string multiplication mentioned in the previous video.. for example:

Python 3.6.2 (v3.6.2:5fd33b5, Jul  8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> count = 5
>>> print(count*"Hello")
HelloHelloHelloHelloHello
>>>

Hope this helps if you have not solved it yet. Good luck!