0

Comparing a sliced string with more than 1 character to another string with is equals False. See Why does comparing strings in Python using either '==' or 'is' sometimes produce a different result?

But comparing only 1 character slices with is equals True. Why?

>>>> 'ab'[1:] is 'b'
True
>>>> 'abb'[1:] is 'bb'
False
masterfloda
  • 2,908
  • 1
  • 16
  • 27

0 Answers0