I am new to python and was thinking of adding two lists.I have two lists list1
and list2
.
To get the result into a new list say list3
, I can simply do this-
list3=list1+list2
But I want to take first 10
elements from list1
and first 20
elements from list2
and get the result in list3
From my experience in other languages,one method is to run a for
loop for 10
elements in list1, keep the result in list3
.Then do the same for 20
elements of list2
. I want to know if there is some other way in python to do this without using loops
. So my question reduces to can I get first n
elements from any list into other list without using loops .
I am using python3
.