Please do not mark duplicated YET. I did read this Python is vs ==
I have read around and noticed ==
vs is
that is
checks if same memory location and ==
is used to compare two values but recently I was using is
by accident BUT to me it's acting weird and I am don't really understand why though.
I am trying to parse a url path to see if the page number matches for example
a = '9'
b = '/category-1-11-9.html'
c = b.split('.html')[0].split('-')[-1]
print(a is c, ' bool') # this gives True
a = '10'
b = '/category-1-11-10.html'
c = b.split('.html')[0].split('-')[-1]
print(a is c, ' bool') # this gives False
I figured if the number is a single digit, I get True
as return and if number is 10 or more I get False
I tried to print
both a
and c
to see their type
and value
, ended up both typeand
value` are the same. But why with a single digit it gives True and double digits it gives False?
I am quite confused with this even after reading articles about is
Using python version 3.7.7