Learn Python
WIP Course Work
7.3
Lesson

WIP Separating a String

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

The position of the letter is called index.

You can see the indexes in the string “Big Binary” as shown below:

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

In the example below, we have separated Big from Big Binary.

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

In the example below, we have changed the index to 2.

Thereby, we can see the output we are getting is only the zeroth position letter and first position letter.

If there is no first index, then the separation starts from the beginning up to the specified index.

In the below example, we have deleted 0 from [0:3].

Thus the output starts from the zeroth position letter B.

If there is no second index then separation starts from the specified index up to the last character.

In the below example, we have deleted 3 from [1:3].

Thus the output starts from the first position and ends with the last position.