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"

david kennedy
david kennedy
2,291 Points

Not really sure where I am going wrong with this question, I can get it to work but I have to define variable count.

count = 8

def printer(count): while count: print "Hi" count = count -1

printer(8)

printer.py
def printer(count):
    while count:
        print "Hi"
        count = count -1

printer(8)

1 Answer

Tobias Helmrich
Tobias Helmrich
31,603 Points

Hey David,

you could solve this challenge easier if you would just multiply your string by the count argument like the challenge's instruction suggests, there is no need for a while loop in this case. You also don't have to call the method yourself as it will be done automatically when the challenge is evaluated. :)

def printer(count):
  print("Hi " * count)
david kennedy
david kennedy
2,291 Points

Thanks that really helped.