Weired behaviour - The slice of empty string not return an error

Yassine Nasri yassine.naasri at gmail.com
Sun Oct 30 10:57:14 EDT 2022


Hello,

len('')  # => 0''[0]    # => error''[::]   # => ''''[::]   # <=> ''[0:len(''):1]

the syntax of slice:

slice(start, end, step)

The start in ''[::] equivalent at index 0 of the ''

Since the index 0 of '' returns an error.

The ''[::] should not return an error logically.


Best regards


More information about the Python-list mailing list