Skip to content

Remove Redundant Slice Index

Documentation Index

Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt

Use this file to discover all available pages before exploring further.

Sourcery refactoring id: remove-redundant-slice-index

Section titled “Sourcery refactoring id: remove-redundant-slice-index”

Removes unnecessary slice indices.

numbers[0 : len(numbers)]
numbers[:]

The default starting value for a slice is 0, so it is unnecessary to explicitly define it. The default ending value is the end of the collection, so it is unnecessary to explicitly define this as well.

This refactoring removes unnecessary slice indices, slightly shortening the code.