[Tutor] Files Merging

Sunil Tech sunil.techspk at gmail.com
Thu Oct 11 15:51:11 CEST 2012


Thanks all for your immediate responses :)

On Thu, Oct 11, 2012 at 6:20 PM, Joel Goldstick <joel.goldstick at gmail.com>wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20121011/26b7e11a/attachment-0001.html>


More information about the Tutor mailing list