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

Yassine Nasri yassine.naasri at gmail.com
Sun Oct 30 10:59:41 EDT 2022


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

Le dim. 30 oct. 2022 à 15:57, Yassine Nasri <yassine.naasri at gmail.com> a
écrit :

> 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