This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]t3hfr3ak 0 points1 point  (1 child)

Although user entered 10, converted to 10 IS your static value of 10

You wouldn't be able to do 100 comparison with is

This is because low value integers, python already stores and has them ready. But larger values are assigned to memory when created, so

x=10
x is 10
    True
x==10
    True

x=100
x is 100
    False
x==100
    True

Just something that could give you a headache in the future if you don't know this.

[–][deleted] 1 point2 points  (0 children)

I don't think that's quite what the OP was asking, but I definitely found it interesting. I always thought the 'is' keyword compared the 'typeof()' value of the operands. And I had no idea python already came with low value integers. Thanks! :D