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 trialAditya Pandey
7,210 PointsWhat does 'is' do?
I don't understand what the 'is' keyword is used for. Can anyone clarify?
1 Answer
James Morris
5,104 PointsHi Aditya,
the "is" keyword compares one value to another and tells you whether the statement is true or not. so for example you can run the code below and both print statements return "True"
a = 1
b = 1
print(a is b)
print(a == b)
Try it out in workspaces.
Best of luck!
Leeland Miller
1,324 PointsLeeland Miller
1,324 PointsYou have to be careful with using
is
though.is
tests for identity, not equality. What that means is it is looking to see if the two values are in the same place in memory.For example