With code
In order to go 'down' you must instruct Python to do so, and also keep in mind that last indice in slice will be excluded:
Documentation >>> Glossary >>> slice
Documentation >>> The Python Standard Library >>> Built-in Functions >>> slice()
The Python Language Reference >>> 6. Expressions >>> 6.3. Primaries >>> 6.3.3. Slicings
name[3:0]
you give Python an order: "give me letters on indices starting from 3 up to 0 which is first to be excluded". As you can't go up 3 -> 0 then there is no slice.In order to go 'down' you must instruct Python to do so, and also keep in mind that last indice in slice will be excluded:
>>> name = 'david' >>> name[2:0:-1] # -1 instructs Python to 'step down' 'va' # letter with index 0 is excluded >>> name[2::-1] 'vad' >>> name[2:None:-1] # this is same as previous but with explicit NoneMore information about slicings in Python documentation:
Documentation >>> Glossary >>> slice
Documentation >>> The Python Standard Library >>> Built-in Functions >>> slice()
The Python Language Reference >>> 6. Expressions >>> 6.3. Primaries >>> 6.3.3. Slicings
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.