home.social

#0based — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #0based, aggregated by home.social.

  1. @mate

    It means the index you supplied is past the end of the list, or before the beginning. List indices start at 0, which sometimes trips people up.

    >>> l = [1, 2, 3]
    >>> l[2]
    3
    >>> l[-3]
    1
    >>> l[3]
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    IndexError: list index out of range
    >>> l[-4]
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    IndexError: list index out of range

    Happy to look at code if you post it.

    #0based #list #python

  2. One point I've never seen mentioned in the Array Indexing Wars is that source code is always numbered from 1.

    Like, even the C standard mandates that the first line of code in a file is numbered 1

    #programming #ArrayIndexing #0based #1based #C

  3. One point I've never seen mentioned in the Array Indexing Wars is that source code is always numbered from 1.

    Like, even the C standard mandates that the first line of code in a file is numbered 1

    #programming #ArrayIndexing #0based #1based #C

  4. One point I've never seen mentioned in the Array Indexing Wars is that source code is always numbered from 1.

    Like, even the C standard mandates that the first line of code in a file is numbered 1

    #programming #ArrayIndexing #0based #1based #C

  5. One point I've never seen mentioned in the Array Indexing Wars is that source code is always numbered from 1.

    Like, even the C standard mandates that the first line of code in a file is numbered 1

    #programming #ArrayIndexing #0based #1based #C

  6. One point I've never seen mentioned in the Array Indexing Wars is that source code is always numbered from 1.

    Like, even the C standard mandates that the first line of code in a file is numbered 1

    #programming #ArrayIndexing #0based #1based #C