compair string with a list??

Jeremy Yallop jeremy at
Wed Aug 21 23:54:01 CEST 2002

* jubafre 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']
| 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]


  'LDA' == x[0][:4]


More information about the Python-list mailing list