I currently have a list such as:
list1 = ['123', '1bc', 'a', 'Machine Learning', '', '7', 'is', '', 'c', 'data science', '', 'python']
How do I change it into a list having elements that has more than 1 character, such as
['123', '1bc', 'Machine Learning', 'is', 'data science', 'python']
that is, it should be removing all the elements that has 1 or less than 1 character.
My actual current list is something like this:
l = ['1', '00:00:05,849 --> 00:00:13,730', 'abdomen', '', '2', '00:00:13,740 --> 00:00:21,269', 'afghan', '', '3', '00:00:21,269 --> 00:00:27,989', 'albic', '', '4', '00:00:27,989 --> 00:00:36,085', 'dug desert']
I want to keep only the elements that have timestamps and its corresponding text. I want to remove everything else. To do so, the easiest way would be to remove the elements with characters 1 or less than 1, right? Because that's what all the remaining elements that are to be removed are.
use List Comprehensions: with len
print([el for el in ist1 if len (el) > 1])
sample output
['123', '1bc', 'Machine Learning', 'is', 'data science', 'python']