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 trialDamian McCarthy
3,656 PointsI'm not getting this one...
Im trying to use the number to keep it true for 5 rotations, then become false. maybe this only makes sense in my head....
def printer(count):
while count == True:
print("Hi")
count -= 1
printer(5)
1 Answer
Dane Parchment
Treehouse Moderator 11,077 PointsStop for a moment and just look at the code that you have written, then try to reason out the logic in your head.
What you are currently doing is looping while the count variable is true. However, your count variable is a number not a boolean so it cannot equal true.
What you should be doing is checking if the count is greater than 0. That way once you subtract it during each loop once it reaches 0 the loop will exit because the count it no longer greater than 0.
I believe you should be able to code this yourself, but if you are still stuck I can provide the answer for you.
Also I suggest rewatching the videos on comparisons, and variable types because you seem to be having a problem with the currently.
Best of luck and never stop coding!
Damian McCarthy
3,656 PointsDamian McCarthy
3,656 PointsI thought that if there was a number than it would be true but as soon as it became zero it became false?
Dane Parchment
Treehouse Moderator 11,077 PointsDane Parchment
Treehouse Moderator 11,077 PointsThat would work if you did were doing it like so:
Where we are using the number itself as a comparitor.
However, in your case you are trying to see if a number type is equal to a boolean type, which is improper.