Image for Slicing

Slicing

Slicing is a way to access a specific part of a sequence, like a list, string, or array, by specifying start and end points. It creates a new, smaller piece containing the elements within that range without changing the original. For example, if you have a list of numbers, slicing lets you quickly extract a subset, like items from position 2 to 4. It's useful for data manipulation, allowing you to work with just the relevant section without copying the entire sequence. Think of it as cutting out a specific segment from a larger piece.