String slicing in Python

You may find that the question on ‘memory’ is addressed here.

As for the last two lines of your code (which are the same?)

print(s[2:] is s[4:])

If you print(s[2:], s[4:]), you’ll see

string ring

… which are clearly different, and as such print(s[2:] is s[4:]) will return False

1 Like