Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python merge two lists alternating

a = [1, 3, 5]
b = [2, 4, 6]

c = []
for x, y in zip(a, b):
  c += [x, y]

print(c)
# [1, 2, 3, 4, 5, 6]
Comment

PREVIOUS NEXT
Code Example
Python :: get the name of a file using os 
Python :: fizzbuzz python solution 
Python :: python print on file 
Python :: Plot regression line from sklearn 
Python :: pandas read_csv column names 
Python :: python how to import library absoluth path 
Python :: Set a random seed 
Python :: make entry bigger in tkinter python 
Python :: how to round off values in columns in pandas in excel 
Python :: pandas sort by columns 
Python :: matplotlib savefig not working 
Python :: grid search cv 
Python :: python print numbers 1 to 10 in one line 
Python :: matplotlib custom legend 
Python :: list tuples and dictionary in python 
Python :: convert price to float python 
Python :: add row in db django 
Python :: list of numbers 
Python :: how to make django model field case insensitive 
Python :: how to start a new django project 
Python :: is there a way to skip the first loop on a for loop python 
Python :: django date formatting 
Python :: how to press enter in selenium python 
Python :: django drop all tables 
Python :: django migrate fake zero 
Python :: alphabet python 
Python :: tkinter slider 
Python :: .text python 
Python :: change to first letter capital list python 
Python :: python dict remove key 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =