Odoo Help

1

How to convert Python Multiple list to list

By
priyankahdp
on 5/15/13, 8:51 AM 1,928 views

here is my python list when i debug it

list: [[4, 1, False], [4, 2, False], [4, 3, False], [4, 4, False], [4, 5, False]]

now i need to convert it to this type list

list: [1,2,3,4,5]

please advice me to implement this.

2
Daniel Reis
On 5/15/13, 3:10 PM

Why not use a one-liner?

>>> source = [[4, 1, False], [4, 2, False], [4, 3, False], [4, 4, False], [4, 5, False]]
>>> result = [x[1] for x in source]
>>> print result
[1, 2, 3, 4, 5]

intelligent ! but for the visibility of code .!!

Borni DHIFI
on 5/15/13, 3:17 PM

thanks dear Daniel..seems its more easier :-)

priyankahdp
on 5/17/13, 1:02 AM
5
Sandeep
On 5/15/13, 9:04 AM

hey priyanka do one think :

 list=[[4, 1, False], [4, 2, False], [4, 3, False], [4, 4, False], [4, 5, False]]
 m=[]
 for i in range(0,len(list)):
     m.extend(list[0])
 m=[4, 1, False, 4, 2, False, 4, 3, False, 4, 4, False, 4, 5, False]

thanks

2
Borni DHIFI
On 5/15/13, 9:01 AM

Hi;

list= [[4, 1, False], [4, 2, False], [4, 3, False], [4, 4, False], [4, 5, False]]      
my_list=[]
for object in list : 
    my_list.append(object[1])


print my_list # give [1, 2, 3, 4, 5]

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)

Stats

Asked: 5/15/13, 8:51 AM
Seen: 1928 times
Last updated: 3/16/15, 8:10 AM