compair string with a list??
Ian Holmes
ianholmes01 at lycos.com
Thu Aug 22 07:19:32 EDT 2002
jubafre at brturbo.com wrote in message news:<mailman.1029956256.29413.python-list at python.org>...
> 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)]
1
>>>
the string.strip() method removes whitespace
More information about the Python-list
mailing list