Why do I get an IndexError (or TypeError, or just wrong results) from “ar[i]” inside “for i in ar”?

When looping over a list, the for variable (in this example i) represents the current element of the list. For example, given ar = [1, 5, 10], i will have the successive values 1, 5 and 10 each time through the loop. Since the length of the list is 3, the maximum permitted index is … Read more

What does ‘index 0 is out of bounds for axis 0 with size 0’ mean?

In numpy, index and dimension numbering starts with 0. So axis 0 means the 1st dimension. Also in numpy a dimension can have length (size) 0. The simplest case is: In [435]: x = np.zeros((0,), int) In [436]: x Out[436]: array([], dtype=int32) In [437]: x[0] … IndexError: index 0 is out of bounds for axis … Read more

Does “IndexError: list index out of range” when trying to access the N’th item mean that my list has less than N items?

If you have a list with 53 items, the last one is thelist[52] because indexing starts at 0. From Real Python: Understanding the Python Traceback – IndexError: IndexError The IndexError is raised when you attempt to retrieve an index from a sequence, like a list or a tuple, and the index isn’t found in the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)