Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
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]