Hey Kumar,
nearly there -
List1 =
['Tyres','windsheild','A\CUnit','Model=Toyota_Corolla']
In other list I have :
List2= ['Corolla','Accord','Camry']
for element1 in List1:
for element2 in List2:
if element2 in element1:
#Do something here, usually a break or continue clause
(Incidentally,'for element in list' is an easier version of for i in
range(len(list)) when you don't need to use index numbers. It just
steps element by element.)
'if x in y' works for strings within strings as well.
Regards,
Liam Clarke
On Mon, 6 Dec 2004 09:57:11 -0800 (PST), kumar s <[EMAIL PROTECTED]> wrote:
> Dear Group,
>
> I have a list that is:
>
> List1 =
> ['Tyres','windsheild','A\CUnit','Model=Toyota_Corolla']
>
> In other list I have :
> List2= ['Corolla','Accord','Camry']
>
> I want to see if Corolla is there in list 1:
>
> The code:
> for i in range(len(List1)):
> if i in range(len(List2):
> print i
>
> If I have 'Corolla' as an element in both list then it
> is easy to find. However, in List1 this element
> appears as 'Model=Toyota_Corolla'.
>
> How can I ask python to match both elements:
> 'Model=Toyota_Corolla' and 'Corolla', where a part of
> element is matching.
>
> please help.
>
> thanks
>
>
> __________________________________
> Do you Yahoo!?
> All your favorites on one personal page â Try My Yahoo!
> http://my.yahoo.com
> _______________________________________________
> Tutor maillist - [EMAIL PROTECTED]
> http://mail.python.org/mailman/listinfo/tutor
>
--
'There is only one basic human right, and that is to do as you damn well please.
And with it comes the only basic human duty, to take the consequences.
_______________________________________________
Tutor maillist - [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor