Python Slicing

Python Slicing

Python Slicing provide a concise way to create sub list, sub string from the existing list and strings respectively without using loop statement or if clauses. Slicing works in similar way for both Strings & Lists.

Slicing statement must have 2 paramater separated by colon to specify start & end position, and 3rd optional parameter also separated by colon to specify the increment.

Syntax: list_or_string_object[start_position : end_position : step]

➠ Examples of String slicing

Examples of List slicing