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 trialJabari Bellamy
9,513 PointsHow to include a single argument and count inside your function and print "Hi" as many times as count argument?
Does anyone have any ideas on how I can solve this code challenge. Any help would be highly appreciated.
def printer(word):
if word == "Hi":
print("Hi "*3)
printer("Hi")
2 Answers
Lukas Coffey
20,382 PointsSo the challenge is asking you to print("Hi")
as many times as the count
argument says. So say if I write this code:
printer(5)
# The output should be:
# HiHiHiHiHi
So, you're taking the string "Hi" and multiplying it by the function argument. You shouldn't need an if:
statement. That help?
Lukas Coffey
20,382 PointsNo problem!
Jabari Bellamy
9,513 PointsJabari Bellamy
9,513 PointsAh, I see, thanks mate for offering me your perspective on this code challenge. It makes sense. Thank you.