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: 2016/02/07 14:51; Updated at: 2016/02/15 01:45