0

How to remove

List=['i', 'b', 'i', 'a', 'i'] I want to remove all the 'i' in the list completely How to do

9th Apr 2020, 1:46 PM
Bai Jilla
Bai Jilla - avatar
6 Respostas
+ 3
li= list(filter(lambda x: x!= 'i',List))
9th Apr 2020, 1:49 PM
Oma Falk
Oma Falk - avatar
+ 2
li = [l for l in List if l!='i'] Or, if you want to keep the list: for i in range(len(List)): if List[i]=='i': del List[i]
9th Apr 2020, 2:03 PM
HonFu
HonFu - avatar
0
list=['i', 'b', 'i', 'a', 'i'] a = list.count('i') for i in range(a): list.remove('i') I hope it helps!!!!
9th Apr 2020, 2:08 PM
ANJALI SAHU
0
li = list('ibiai') for i in li: if i=='i': li.remove(i) print(li)
9th Apr 2020, 3:21 PM
Justus
Justus - avatar
0
# use the lambda function List = list(filter(lambda x: x!= 'i' , List))
10th Apr 2020, 7:55 AM
Tijan
Tijan - avatar
0
list=["i","b","i","a","i"] s=[] for c in list: if c!="i": s.append(c) print(s)
11th Apr 2020, 7:50 AM
Ashish Singh
Ashish Singh - avatar