Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
I don't understand
I don't know how to * it or use the right variable. If you understand please help.
def printer(count): int(printer(count)*print('Hi '))
Ben Reynolds35,170 Points
You can simply multiply a string by a number in a print statement and it will repeat, like this:
def repeat_string(num): print("Some string" * num)
If you wanted to cast it to an int (not needed for this exercise, but still a good idea in a real app) you'd probably want a try/catch like this:
def repeat_string(num): try: int(num) print("Some string" * num) except ValueError: # this will run if an exception is caught