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 trialMaximillian Quick
210 PointsHow do I determine if a number is an integer? I don't remember learning that lesson.
just started and not sure how to approach.
1 Answer
Steven Parker
231,275 PointsYou forgot to indicate which course and lesson you are on, so there may be another way that relates more to your course. But one way to do this is to compare the number with the result of truncating any fractional part. If they are the same, the number was already an integer to begin with:
include math
if mynumber == math.trunc(mynumber):
// it is an integer
else:
// it has a fractional component
For future questions, you might want to take a look at this video about Posting a Question.