On 7/20/2014 5:40 AM, Martin S wrote:

while c >=0:
         x=games[c][0]
         if x=="#":
             del games[c] #This removes the comments from the file parsed
         else:
             games[c].rstrip('\n') #This does nothing, expected to remove \n

Chris already pointed out error here.

         c=c-1
     # Now we have a list with only proper lines

I believe what you are aiming for is

games = [line.rstrip('\n') for line in games if line[0] != '#']

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to