I cannot write s[::-1]
which reverses the string s
using explicit indices. I want to write s[a:b:-1]
but I don't know what to put for a
and b
. Here is a code sample, it should produce fedcba
:
s = 'abcdef'
s[::-1]
From the documentation:
Slice indices have useful defaults; an omitted first index defaults to zero, an omitted second index defaults to the size of the string being sliced.