Here’s one way to do it by slicing:
>>> list1 = ['f', 'o', 'o']
>>> list2 = ['hello', 'world']
>>> result = [None]*(len(list1)+len(list2))
>>> result[::2] = list1
>>> result[1::2] = list2
>>> result
['f', 'hello', 'o', 'world', 'o']
More Related Contents:
- if and else in Python,if age is true grade is false,this program print is wrong
- Query By Humming system [closed]
- Fastest way to check if a value exists in a list
- How do I concatenate text files in Python?
- Convert Django Model object to dict with all of the fields intact
- Generating permutations with repetitions
- Django – Login with Email
- Dynamic instantiation from string name of a class in dynamically imported module?
- How to terminate a thread when main program ends?
- subprocess: deleting child processes in Windows
- Convert list to tuple in Python
- How to create module-wide variables in Python? [duplicate]
- How can I make sure if some HTML elements are loaded for Selenium + Python?
- PyCharm import external library
- How to copy InMemoryUploadedFile object to disk
- How to read bits from a file?
- Generating SIMD instructions from Cython code
- Assigning (instead of defining) a __getitem__ magic method breaks indexing [duplicate]
- Mapping ranges of values in pandas dataframe [duplicate]
- How do order of operations go on Python?
- Pandas can’t read hdf5 file created with h5py
- Formatting long numbers as strings
- create an image with border of certain width in python
- How to plot percentage with seaborn distplot / histplot / displot
- Sort invariant for numpy.argsort with multiple dimensions
- Error with double backslash in Windows path in Python [duplicate]
- Class-level read-only properties in Python
- Extract csv file specific columns to list in Python
- Fit a non-linear function to data/observations with pyMCMC/pyMC
- Overlap between mask and fired beams in Pygame [AI car model vision]