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 trialDebasis Nath
3,316 Pointswhat i have done wrong here
arguments
def printer(count):
if count=10:
print("HI")
3 Answers
Jennifer Nordell
Treehouse TeacherHi there, Debasis! This challenge is asking you to define a function that has one parameter named count
. This part you did correctly, so kudos! But then it's asking you to print out "Hi" times the number that's equal to count. You have an if statement which actually isn't a conditional as it contains a single equals sign. That's not a comparison, it's an assignment. But in this case, neither an assignment nor a comparison are necessary.
You can take any string and multiply it by an integer to print it that number of times. So for example, if I wanted to print out "Treehouse" three times, I could do
print("Treehouse" * 3)
This would print out "TreehouseTreehouseTreehouse". However, they want an extra space in your output, and you don't know how many times you should print it because Treehouse is going to send in that information. Take a look:
def printer(count):
print("Hi " * count)
You can think of the the parameter as being a local variable declaration. It's going to accept a piece of information coming into the method and then set count equal to that. Whatever number Treehouse sends into our printer
function will now be stored in count. So if Treehouse send in 5, this will now print out "Hi Hi Hi Hi Hi". Note the space that I added after the "Hi" so that it won't appear all squished together.
Hope this helps!
Justin Duncan
8,465 Pointscount is not equal to 10. You have to make count equal to 10 for your print statement to work :)
Jennifer Nordell
Treehouse TeacherHi Justin! I have moved your comment to an answer to allow it to be eligible for voting and to mark this question as answered on the forums. Thanks for helping out in the Community!
Debasis Nath
3,316 Pointsoh! thank you.:)