a = ['ali', ',', 'ali', ',', 'ali', ',', 'ali', ',', 'ali', ',']
def fan(s):
for item in range(0, len(s)):
while s[item] == ',':
s.remove(',')
return s
fan(a)
Traceback (most recent call last):
File "<pyshell#326>", line 1, in <module>
fan(a)
File "<pyshell#325>", line 3, in fan
while s[item] == ',':
IndexError: list index out of range
a = ['ali', 'ali', 'ali', 'ali', 'ali']
my question is .. why getting error ! , although my code work and remove ',' from the list ?! ...
Created at: Feb. 7, 2016, 2:51 p.m.; Updated at: Feb. 15, 2016, 1:45 a.m.