Is there a way to substring a string in Python, to get a new string from the third character to the end of the string?
Maybe like myString[2:end]
?
One example seems to be missing here: full (shallow) copy.
>>> x = "Hello World!"
>>> x
'Hello World!'
>>> x[:]
'Hello World!'
>>> x==x[:]
True
>>>
This is a common idiom for creating a copy of sequence types (not of interned strings), [:]
. Shallow copies a list, see Python list slice syntax used for no obvious reason.