Is there a way to substring a string in Python, to get a new string from the 3rd character to the end of the string?
Yes this actually works if you assign
>>> end = None
>>> myString = '1234567890'
Slice notation has 3 important arguments:
Their defaults when not given are
None - but we can pass them explicitly:
>>> stop = step = None
>>> start = 2
If leaving the second part means 'till the end', if you leave the first part, does it start from the start?
Yes, for example:
>>> start = None
>>> stop = 2
Note that we include start in the slice, but we only go up to, and not including, stop.
When step is
None, by default the slice uses
1 for the step. If you step with a negative integer, Python is smart enough to go from the end to the beginning.