From a list like this (original_list):
[[], (['2313240'], 51.0), (['2313301'], 55.0), (['2313467'], 51.0)]
I need create another list (result_list) with only the [0] elements (for example the 2313240), so I'm trying to extract it using:
for row in range(1, len(original_list)):
result_list.append(original_list[row][0][0])
But it's result is similar to this:
['2313240', '2313301', '2313467']
When I actually want to achieve something like this (elements without brackets):
[2313240, 2313301, 2313467]
And so I'm able to use it as a parameter to a query:
cursor.execute(sql,[result_list])
Right now it logs the following error:
pymysql.err.InternalError: (1241, 'Operand should contain 1 column(s)')
I have no clue how to solve this since I'm begginer in Python.
Just cast to int
before appending the values to the array:
result_list.append(int(original_list[row][0][0]))