• check it .

 

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 ?! ...