compair string with a list??
Jeremy Yallop
jeremy at jdyallop.freeserve.co.uk
Wed Aug 21 17:54:01 EDT 2002
* jubafre at brturbo.com
| 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']
|
| the nodes of the list means the lines of the file opened.
|
| I want to compair one string with a part of line
| for example 'LDA'==x[0], this not true because x[0] is all the node ('\tLDA \tD1'),
| i want to compair 'LDA'== '\tLDA', how i can get this??????
Depending on exactly what you want, try:
'LDA' == x[0].split(' ')[0]
or
'LDA' == x[0][:4]
Jeremy.
More information about the Python-list
mailing list