Let’s say I have 2 following lists:
list1 = [1,1,1,1]
list2 = [3,3,3,3]
I want the result of join to be:
list3 [4,4,4,4]
What’s would be the best way to do it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Extremely similar to Ignacio’s answer, but for a tiny bit more brevity:
or
I prefer the map version myself.
Edit: As JBernardo rightly points out, if using Python 2.x you should replace zip with its iterator counterpart in itertools.izip for efficiency, but zip uses iterators by default in Python 3.