[Tutor] How to get value of sublist as return to verify in other file

shweta kaushik coolshwetu at gmail.com
Tue Jan 6 06:40:24 CET 2015


Hi all,

Thanks for the help.

I am able to resolve the issue. I need to return all values in one file and
in other file I need to reading the response as response[0] , response[1]
and so on..

Shweta
On Jan 6, 2015 8:32 AM, "shweta kaushik" <coolshwetu at gmail.com> wrote:

> Hii Alan,
>
> Thank you..
>
> I want to put the value of sublist[3] into another file (test case) for
> verification purpose.
>
> Shweta
> 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[3] == 4:
>>> ...        print sublist[3]
>>> ...
>>> 4
>>> 4
>>> 4
>>> 4
>>> I want sublist[3] 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
>> statement
>>
>>  And also i want to return same sublist value i.e. sublist[3] and want to
>>> get the value of sublist[3] 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[3] in another file."
>>
>> Do you want to read another file and compare
>> it to sublist[3]?
>> Or do you want to put the value of sublist[3]
>> into another file?
>>
>> --
>> Alan G
>> Author of the Learn to Program web site
>> http://www.alan-g.me.uk/
>> http://www.amazon.com/author/alan_gauld
>> Follow my photo-blog on Flickr at:
>> http://www.flickr.com/photos/alangauldphotos
>>
>>
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> To unsubscribe or change subscription options:
>> https://mail.python.org/mailman/listinfo/tutor
>>
>


More information about the Tutor mailing list