_Hello, world! I have the problem with removing elements from multiple list. I have a multiple list.
print("Preparation")
print(dateTableMonthValues)
It prints me:
[['4:10'], ['3:20'], ['3:45'], ['32:05'], ['5:00'], ['5:00'], ['5:00'], ['5:00'], ['5:00'], ['5:00'], ['5:00'], ['35:00'], ['3:45'], ['5:00'], ['5:00'], ['2:30'], ['2:30'], ['3:45'], ['6:15'], ['28:45'], ['5:00'], ['5:00'], ['7:55'], ['7:05'], ['5:00'], ['5:50'], [], ['35:50']]
From this array I need to remove several elements, for example ['32:05'], ['35:00'], ['28:45'], [], ['35:50']]
Ok, I have found these values and:
for i in range(len(dateTableDayValues)):
week = dateTableDayValues[i][0]
print(dateTableDayValues[i][0])
if week[3] == 'w':
print('w')
dateTableMonthValues[i].pop(0)
print("Check")
print(dateTableMonthValues)
Now it prints me:
[['4:10'], ['3:20'], ['3:45'], [], ['5:00'], ['5:00'], ['5:00'], ['5:00'], ['5:00'], ['5:00'], ['5:00'], [], ['3:45'], ['5:00'], ['5:00'], ['2:30'], ['2:30'], ['3:45'], ['6:15'], [], ['5:00'], ['5:00'], ['7:55'], ['7:05'], ['5:00'], ['5:50'], [], []]
So, I have two questions. Fisrtly, why method 'pop' didn't remove the elements, cause I still have elements like this: '[]'. Secondly, how can I deleted from array (list) these empty elements '[]' for defining the sum of all elements? It's not working:
if dateTableMonthValues[i][0] == []:
del dateTableMonthValues[i][0]
dateTableMonthValues[i].pop(0)
Old question: So, when I trying to access list[3][0] it has wrote me "list index out of range". So I decided that the element was removed.
But anyway I couldn't to define the sum of all my elements. I still continue get the message
IndexError: list index out of range
Help me please how can I solve the problem?