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"

Sumanta Patel
Sumanta Patel
560 Points

problem

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

printer.py
def printer(count):
    print({} * "Hi ".format(count))
printer(5)
Sumanta Patel
Sumanta Patel
560 Points

what is wrong in it.. ?

2 Answers

I'm going to list out the lines you wrote along with if it's correct or not:

  1. :white_check_mark: You define a function. You did this properly :smile:
  2. :x: You print "Hi " times times. Doesn't seem to do that! I have no idea why you have {} in there.
  3. :x: Remember, you don't need to call the function. The code challenge does that for you!

Also, you give you a hint on the repeating "Hi ": You can multiply a string by a number, like this! :

Pretend I'm in the Python Shell

>>> 'a' * 5
'aaaaa'
>>> 'ab' * 3
'ababab'
>>> 'Hi ' * 5
'Hi Hi Hi Hi Hi '

I hope these hints help you :grin:

If you still continue to fail, please post your new code snippet. Read the Markdown Cheatsheet to see how. The link is located below a comment/answer box.

:dizzy: ~Alex :dizzy: