Light Mode
Dark Mode
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 ?! ...

Attachment
  • check
Created: Feb. 7, 2016, 2:51 p.m.
Updated: Feb. 15, 2016, 1:45 a.m.
0
4
User avatar
hosam.mae