python list.index('') fails to find string in list if string is in list[0] - why? how do i find it? -


am going mad?

in tests python list.index('') fails find string in list if string in list[0]!!!

why? how find it?

here example code:

list1 = ['wtf', '2.09', '\xc2\x80document.write(currencyformat(currency.convert((209/100),"gbp","eur")));','0.00', 'feminised', '6.88', '\xc2\x80document.write(currencyformat(currency.convert((688/100),"gbp","eur")));', 'regular', 'x10', '20.90', '\xc2\x80document.write(currencyformat(currency.convert((2090/100),"gbp","eur")));', 'feminised', 'x12', '82.56', '\xc2\x80document.write(currencyformat(currency.convert((8256/100),"gbp","eur")));'] list2 = ['1','2','3','4','5', '1'] if list1.index('0.00'):     print "i found 0.00 in list 1 if in position[0], cannot find using index('0.00') - appears twice gives?" if list2.index('1'):     print 'weird' else:     print 'i did not find 1 in list 2 thought there (twice infact)... wtf?' print 'i can find want search string >>> ' + list2[0] print 'or like want search string >>> ' + list2[-1] 

this give me following result:

i found 0.00 in list 1 if in position[0], cannot find using index('0.00') - appears twice gives? did not find 1 in list 2 thought there (twice infact)... wtf? can find want search string >>> 1 or like want search string >>> 1 

i think must missing obvious... cannot figure out or find answer... please me find 'wtf' in list1 or '1' in list2 searching string.....

when if list1.index('1'), testing whether index of '1' in list boolean true. index zero, boolean false. if block doesn't run.

if want know if it's in there, if '1' in list1.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -