String slicing: extrace section : String Slice « String « Python






String slicing: extrace section

String slicing: extrace section
S = 'spam'
print S[1:3], S[1:], S[:-1]     # slicing: extract section

           
       








Related examples in the same category

1.String SliceString Slice
2.Strings can be subscripted (indexed)Strings can be subscripted (indexed)
3.An invariant of slice operations: s[:i] + s[i:] equals sAn invariant of slice operations: s[:i] + s[i:] equals s
4.Degenerate slice indicesDegenerate slice indices
5.Negative Indices numbers: start counting from the rightNegative Indices numbers: start counting from the right