add item from list to another without using loop

0 votes
32 views
asked Oct 3 by anonymous

I wan to efficiently add one list item to another without using loop.

a = []
b= [1,2,3]
a.append(b)
[[1, 2, 3]]

but i need to get

[1,2,3] in a

how can i do it efficiently.

1 Answer

0 votes
answered Oct 3 by anonymous

Thanks to python it is very good in terms of handling list, dict..

you can do python list.extend method instead of 'append' when adding to another list

list1.extend(listb)
...