Re: [Tutor] Unpacking lists

2014-07-09 Thread Alan Gauld
On 09/07/14 02:44, Robert Nanney wrote: #!/usr/bin/python #list_test2.py list1 = [1, 8, 15] list2 = [2, 9, 16] list3 = [[3, 4, 5, 6], [10, 11, 12, 13], [17, 18, 19, 20]] list4 = [7, 14, 21] one_list = zip(list1, list2, list3, list4) first_round = [one_list[x][y] for x in range(len(list3)) for

Re: [Tutor] Unpacking lists

2014-07-09 Thread Alan Gauld
On 09/07/14 06:58, Alan Gauld wrote: list1 = [1, 8, 15] list2 = [2, 9, 16] list3 = [[3, 4, 5, 6], [10, 11, 12, 13], [17, 18, 19, 20]] list4 = [7, 14, 21] I'm thinking something like result = [] for L in (list1,list2,list3): if isinstance(L,list) result += L else:

Re: [Tutor] Unpacking lists

2014-07-09 Thread Wolfgang Maier
On 09.07.2014 08:16, Alan Gauld wrote: On 09/07/14 06:58, Alan Gauld wrote: list1 = [1, 8, 15] list2 = [2, 9, 16] list3 = [[3, 4, 5, 6], [10, 11, 12, 13], [17, 18, 19, 20]] list4 = [7, 14, 21] I'm thinking something like result = [] for L in (list1,list2,list3): if isinstance(L,list)

[Tutor] Unpacking lists

2014-07-08 Thread Robert Nanney
Hello All, I have the following code. The idea is to have one list that contains all of the items from the different iterable types and maintain the order of the items. Python 2.7.6 |Anaconda 2.0.0 (x86_64)| (default, May 27 2014, 14:58:54) #!/usr/bin/python #list_test2.py list1 = [1, 8, 15]