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

Print "hi"

Hey everyone!

While I'm aware this code works:

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

I want to know why my code did not.

def printer(count): for int in count: print "Hi "

printer(3)

Could someone tell me the difference? I figure count must be an int, therefore I can multiply the string by the integer (as the instructions state). What is wrong with my code?

1 Answer

count has to be a list or a tuple. the in keyword specifies were looking for an item in a list or collection of data.