compair string with a list??

Ian Holmes ianholmes01 at
Thu Aug 22 13:19:32 CEST 2002

jubafre at wrote in message news:<mailman.1029956256.29413.python-list at>...
> I open a file teste.asm in a list like that:
> x=['\tLDA \tD1', '\tADD \tD2', '\tSTA \tD3', '\tHLT\t', '', 'D1:\tDB \t3', 'D2:\tDB \t2', 'D3:\tDB \t']

Not sure how efficent this is but you could try

>>> import string 
>>> x=['\tLDA \tD1', '\tADD \tD2', '\tSTA \tD3', '\tHLT\t', '',
'D1:\tDB \t3', 'D2:\tDB \t2', 'D3:\tDB \t']
>>> comparestring = 'LDA'
>>> comparestring == string.strip(x[0])[:len(comparestring)]

the string.strip() method removes whitespace

More information about the Python-list mailing list