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 trialMikael Djerrou
Courses Plus Student 356 Points#can you please elaborate about the function of == 0 in the following line of code is_fizz = number % 3 == 0.
from what I understand it ckecks if there is a remainder but its still not crystal clear. Thanks in advance.
1 Answer
Alexander Davison
65,469 Pointsnumber % 3 == 0
checks to see if number
is divisible by 3. %
is called "modulo", and you can think of it as a "remainder" operator. It divides the left side by the right and it calculates the remainder. So number % 3 == 0
is checking if the remainder is zero. If the remainder indeed is zero, that means number
is divisible by 3.
Mikael Djerrou
Courses Plus Student 356 PointsMikael Djerrou
Courses Plus Student 356 Pointsthank you Alexander Now it's crystal clear!