This example shows how to perform indexing and slicing on strings in python.
Output
str = ABCDEFG
Indexing
A : First characters of string
B : Second characters of string
G : Last characters of string
G : Last characters of string
Slicing
BC : First 2 characters of string
BCDEFG : First to end of string
ABCDEFG : Print the full string
ABCDE : Print the string except last two characters
Comments
Post a Comment