Psst! Check what courses we have in our offer, and get them all here to save $727. Act fast–this deal is available only 3/14–3/21.
Introduction
Quick recap
Indexing and slicing
13. Slicing with steps
Summary

Instruction

Perfect. You can also include a third number when slicing:

alphabet = 'abcdefghijklmnopqrstuvwyxz'
alphabet[3:10:2]

The third number is the step. The code above will return every second character from the string, beginning from index 3 (inclusive) and finishing at index 10 (exclusive). This diagram will help you understand what happens:

Slicing with step

Exercise

A secret message was encoded in the string secret_message. To decode the message, print every other character, beginning at the character with the index 1.

Stuck? Here's a hint!

Use secret_message[1::2]