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.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
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.
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 .!!
thanks dear Daniel..seems its more easier :-)
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
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]
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
0
thg 3 25
|
907 | ||
|
4
thg 4 24
|
173366 | ||
|
0
thg 12 23
|
1761 | ||
|
5
thg 2 25
|
225641 | ||
|
1
thg 12 22
|
2766 |