Nov-03-2019, 09:47 AM
Hello,
I have a python 2D array that looks like this:
Is there a way in pure Python, without Numpy or other apps?
Thank you
In [
I have a python 2D array that looks like this:
Labels = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", \ "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", \ "AA", "BB", "CC", "DD", "EE", "FF", "GG", "HH", "II", "JJ", "KK", "LL", \ "MM", "NN"] Load = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] Array = [Labels, Load] print(Array) [['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'BB', 'CC', 'DD', 'EE', 'FF', 'GG', 'HH', 'II', 'JJ', 'KK', 'LL', 'MM', 'NN'], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] type(Array) Out[11]: listI would like to select the element corresponding to the value "A", but how? of course:
Error:Array["A", 0]
Traceback (most recent call last):
File "<ipython-input-14-1b9f724cd495>", line 1, in <module>
Array["A", 0]
TypeError: list indices must be integers or slices, not tuple
`Is there a way in pure Python, without Numpy or other apps?
Thank you
In [