--- Begin Message ---
Hello, python creators and bug fixers.
I have same strange Basic-type problem time after time.
Deleting elements of lists - is Basic of basics thing. And i can't count
on it. It doesn't work in some cases.
I found a simple example, and example of my problem - to modify the string
data that i got from parsing internet, web-data - this is the case i got
the problem.
Simple Example 1.
I expect to delete all/any elements by index from list by using del,
.remove(), pop() - it must work as usually. But that doesn't happens.
_list = list(range(50))
for i, el in enumerate(_list):
del _list[i]
print(_list)
result:
# [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35,
37, 39, 41, 43, 45, 47, 49]
Same for pop(i) and remove(el).
Works only filter(), creating new _list2 with .append(<filtered elements>)
, with SAME IF-statements - as for delete.(thats for Example 2 and problem
i met with)
Example 2.
I got a string from parsing something from internet. This is a body of one
message from my Gmail this time.
And there is no any way to delete empty elements in existing list to
pretty the final output-data.
Sometimes it deletes random elements, but not all. Sometimes deletes
nothing.
Another diagnose - tried to take len() of of each element, and it says 0
to non zero elements.
The only solution is to create a new list and append needed items instead
of delete non-needed in first-list.
There are many EMPTY elements. I do .split("'r\n") and trying to run a
FOR-cycle.
The list example:
['Вы вошли в аккаунт Google с нового Xiaomi HM Note 2', '', '', '', 'Для
завершения настройки установите официальные приложения от Google.', '',
'', 'Google Sheets', '', 'Google Sheets', '', 'Создавайте таблицы и
работайте над ними вместе', '', '4.5/5 Stars', '', '', '', '', '',
'СКАЧАТЬ', '', '', '', '', '', '', '', 'Google Calendar', '', 'Google
Calendar', '', 'Все ваши календари, мероприятия и встречи в одном
приложении', '', '', '', '', '', '', '', 'СКАЧАТЬ', '', '', '', '', '',
'', '', 'Google Duo', '', 'Google Duo', '', 'Проводите видеовстречи с
высоким качеством изображения', '', '4.5/5 Stars', '', '', '', '', '',
'СКАЧАТЬ', '', '', '', '', '', '', '', 'Не отвечайте на это письмо. Вы
получили это сообщение, так как недавно ', 'активировали свой аккаунт
Google на Xiaomi HM Note 2.', '', '', '', '© 2018 Google LLC 1600
Amphitheatre Parkway, Mountain View, CA 94043, USA', '', '', '', '',
'—————————————————————————————', '', '', '', '']
With Regards.
--- End Message ---