Why does Python show the whole array?

Terry Reedy tjreedy at udel.edu
Thu Apr 9 05:29:53 EDT 2009


Lawrence D'Oliveiro wrote:
> In message <o0tot492cfjj2g180p15irievp6crpc4ih at 4ax.com>, Gilles Ganault 
> wrote:
> 
>> test = "toto at gmail.com"
>> isp = ["gmail.com", "yahoo.com"]
>> for item in isp:
>> if test.find(item):
>> print item
>> ======= output
>> gmail.com
>> yahoo.com
>> =======
> 
> This is why conditional constructs should not accept any values other than 
> True and False.

Nonesense.  Just use 'if item in test:' which tells you all the info you 
are using.   str.find returns an index that you ignore, so don't use it.




More information about the Python-list mailing list