Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32110
| References | (11 earlier) <CAFqGZRE57tJTD8HNvxR0rR43scOydnpLcFNOmykcabFuXAAh4Q@mail.gmail.com> <CA+vVgJWmvZ+ixfunHzse+urq9uaGSq4k7WyZCkjGV4WuuLGGvA@mail.gmail.com> <CAFqGZRFdC9aF3STnX9GAcKmwz8=R5vPih2R+Uex_G5KtcdDyZw@mail.gmail.com> <CA+vVgJW9MVtmw+M=Fp2Qy0=WSLTf0EEY0pA3rm_wuWBnDeTsOQ@mail.gmail.com> <CAFqGZREEvDV=MrGCb1g-ZdHu=uENMsoJ05tMKeX5K61NfZAZEQ@mail.gmail.com> |
|---|---|
| Date | 2012-10-25 06:17 -0400 |
| Subject | Re: can we append a list with another list in Python ? |
| From | David Hutto <dwightdhutto@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2832.1351160234.27098.python-list@python.org> (permalink) |
On Thu, Oct 25, 2012 at 6:12 AM, inshu chauhan <insideshoes@gmail.com> wrote: > > > On Thu, Oct 25, 2012 at 12:04 PM, David Hutto <dwightdhutto@gmail.com> > wrote: >> >> On Thu, Oct 25, 2012 at 5:58 AM, inshu chauhan <insideshoes@gmail.com> >> wrote: >> > Yes Dave ..You are right and my problem is solved now.. Thanx to all... >> > >> > >> > On Thu, Oct 25, 2012 at 11:55 AM, David Hutto <dwightdhutto@gmail.com> >> > wrote: >> >> >> >> On Thu, Oct 25, 2012 at 5:51 AM, inshu chauhan <insideshoes@gmail.com> >> >> wrote: >> >> > >> >> > >> >> >> >> >> >> Is this what you mean: >> >> >> >> >> list_0 = [] >> >> list_1 = [i for i in range(0,5)] >> >> list_2 = [i for i in range(5,11)] >> >> list_0.append(list_1) >> >> list_0.append(list_2) >> >> >> >>> for i in list_2: >> >> >> ... list_1.append(i) >> >> >> ... >> >> >> >>> list_1 >> >> >> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >> >> >> >> >> >> >> >> >> or would another example help you out more? >> >> > >> >> > >> >> > No but really sorry this is what I DONT WANT....... >> >> > >> >> > The output I want to have is : >> >> > >> >> > [ [0, 1, 2, 3, 4 ], [5, 6, 7, 8, 9, 10] ]..... >> >> >> >> Then, this is what you want : >> >> >> >> >>david@david-desktop:~$ python >> >> Python 2.7.3 (default, Aug 1 2012, 05:16:07) >> >> [GCC 4.6.3] on linux2 >> >> Type "help", "copyright", "credits" or "license" for more information. >> >> >>> list_0 = [] >> >> >>> list_1 = [i for i in range(0,5)] >> >> >>> list_2 = [i for i in range(5,11)] >> >> >>> list_0.append(list_1) list_0 = [list_1,list_2] >> >> >>> list_0.append(list_2) >> >> >>> list_0 >> >> [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9, 10]] >> >> if you have a format for the lists, there might be an easier way, or >> simpler. How are the lists coming in? >> >> The list are in form of >> >> first list like [(x,y,z) ] >> >> and another as [(a,b,c), (a+i, b+i, c+i).............] >> This shows tuples though, not appended lists, which are immutable. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: can we append a list with another list in Python ? David Hutto <dwightdhutto@gmail.com> - 2012-10-25 06:17 -0400
csiph-web