[Tutor] Files Merging

Dave Angel d at davea.name
Thu Oct 11 14:00:04 CEST 2012


On 10/11/2012 07:13 AM, Sunil Tech wrote:
> Hi all,
>
> Greetings to you...
> it been so helpful for me to go through your all mails & support & i wish
> it still continues.
>
> I have two text files.
>
> text1 contains
>
> This is from Text1 --- 1st line
> This is from Text1 --- 2nd line
> This is from Text1 --- 3rd line
> This is from Text1 --- 4th line
> This is from Text1 --- 5th line
>
> text2 contains
> This is from Text2 --- 1st line
> This is from Text2 --- 2nd line
> This is from Text2 --- 3rd line
> This is from Text2 --- 4th line
> This is from Text2 --- 5th line
>
>
> i want result in text3 like
>
> This is from Text1 --- 1st line
> This is from Text2 --- 1st line
> This is from Text1 --- 2nd line
> This is from Text2 --- 2nd line
> This is from Text1 --- 3rd line
> This is from Text2 --- 3rd line
> This is from Text1 --- 4th line
> This is from Text2 --- 4th line
> This is from Text1 --- 5th line
> This is from Text2 --- 5th line
>
> but condition is "should not use any loops"
>
> waiting for your reply,
> thank you in advance.
>
> Regards,
> Sunil G.
>
>

What are the other constraints on this homework assignment?  Are list
comprehensions permitted?  Seems likely you can do it readily with a
list comprehension using zip().  One line, total.



-- 

DaveA



More information about the Tutor mailing list