[Tutor] Files Merging
Joel Goldstick
joel.goldstick at gmail.com
Thu Oct 11 14:50:10 CEST 2012
On Thu, Oct 11, 2012 at 8:30 AM, eryksun <eryksun at gmail.com> wrote:
> On Thu, Oct 11, 2012 at 7:13 AM, Sunil Tech <sunil.techspk at gmail.com> wrote:
>>
>> text1 contains
>> This is from Text1 --- 1st line
>> ....
>>
>> text2 contains
>> This is from Text2 --- 1st line
>> ....
>>
>> i want result in text3 like
>> This is from Text1 --- 1st line
>> This is from Text2 --- 1st line
>> ....
zip gets you tuples. map can operate on those tuples
I just tried this:
>>> x = [1,2,3]
>>> y = [4,5,6]
>>> def print_2(t):
... print t[0], t[1]
...
>>> z = zip(x,y)
>>> z
[(1, 4), (2, 5), (3, 6)]
>>> r = map(print_2, z)
1 4
2 5
3 6
>>>
You need to write a function that writes the tuple to a file. It will
look something like my print_2() function
--
Joel Goldstick
More information about the Tutor
mailing list