String Slicing in Python

What is the output of this code snippet?


word = "bender"

The language feature slicing does not only apply to lists, but also to strings. As both lists and strings are sequencing types, slicing is only one among several similarities. For example, you can also iterate over the characters in a string using the for loop (e.g. for c in word).

Only half of the finxter users can solve this puzzle. The other half of the users have problems identifying the correct end index of the slice. Recap, the end index is not included into the slice. Here you can see the indices of the puzzle word.

b e n d e r
0 1 2 3 4 5


Are you a master coder?
Test your skills now!


Related Video




Leave a Comment

Your email address will not be published. Required fields are marked *