[Tutor] How to get value of sublist as return to verify in other file
coolshwetu at gmail.com
Tue Jan 6 04:02:06 CET 2015
I want to put the value of sublist into another file (test case) for
On Jan 6, 2015 6:09 AM, "Alan Gauld" <alan.gauld at btinternet.com> wrote:
> On 05/01/15 17:38, shweta kaushik wrote:
> list = [[1,2,3,4,5],[2,3,4,4,6],[3,4,5,4,6],[1,4,5,4,8]]
>>>>> for sublist in list:
>>>> ... if sublist == 4:
>> ... print sublist
>> I want sublist value when matched first time and don't want the value
>> for second match.
> You need to break out of the for loop.
> The command to do that is 'break'
> Just add a break on a line after the print
> And also i want to return same sublist value i.e. sublist and want to
>> get the value of sublist in another file.
> I'm not sure I understand what you mean there.
> If you break out of the loop you can still access
> your loop variable. But I'm not sure what you mean
> by "get the value of sublist in another file."
> Do you want to read another file and compare
> it to sublist?
> Or do you want to put the value of sublist
> into another file?
> Alan G
> Author of the Learn to Program web site
> Follow my photo-blog on Flickr at:
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
More information about the Tutor