Learn Python

Separating a string

In a string, the position of a letter is called index. As shown in the table given below, index count starts from zero and even spaces have an index.

B I G space B I N A R Y
0 1 2 3 4 5 6 7 8 9

We can separate a part of a string by using the colon (“:”) operator.

In the example given above, we have separated ‘Big’ from the string Big Binary.

The operator considers the zeroth position character but excludes the last character.

In the example above, try changing the indexes to extract different parts of the string.