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 trialRyan Sladek
427 PointsHow to find the right number of "Hi's"
I think I am having a problem figuring out how to get this code to loop. With the code I have right now my error message says "The number of "Hi's" is not specified.
def printer(count):
print("Hi ")
1 Answer
Keifer Joedicker
5,869 PointsLook at the count argument as an alias for the number that will pass through when the function is called.
Your code is a template for how that function's alias will be manipulated.
The number passed through will be used to return a new string with "Hi" repeated count amount of times.
so the template to follow in order to return the desired outcome is ("Hi" * count):
printer(1)
"Hi " * 1 = "Hi "
printer(2)
"Hi " * 2 = "Hi Hi "
printer(3)
"Hi " * 3 = "Hi Hi Hi "
def printer(count):
print("Hi" * count)
ilya A
3,802 Pointsilya A
3,802 Points("Hi" * count) = Hi Hi Hi Hi Hi (Does count mean (multiply by 5?))