K
K
K A2020-04-13 23:30:14
Python
K A, 2020-04-13 23:30:14

What are the options for merging lists?

There are two lists:

a = ['one', 'two', None, 'four', None]
b = [None, None, 'three', None, 'five']

How to get the:
a = ['one', 'two', 'three', 'four', 'five']

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Pankov, 2020-04-13
@russrage

a = [x or y for x, y in zip(a, b)]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question