>>> l = ['a', 'c', 'e', 'b']
>>> [x for pair in zip(l,l) for x in pair]
['a', 'a', 'c', 'c', 'e', 'e', 'b', 'b']
Or
>>> from itertools import repeat
>>> [x for item in l for x in repeat(item, 2)]
['a', 'a', 'c', 'c', 'e', 'e', 'b', 'b']
More Related Contents:
- List comprehensions
- How to create the following lists with list comprehensions? [closed]
- Find a unique element in a list [closed]
- What does “list comprehension” and similar mean? How does it work and how can I use it?
- How to find all occurrences of an element in a list
- List comprehension on a nested list?
- Pythonic way to print list items
- if else in a list comprehension [duplicate]
- Transpose a matrix in Python [duplicate]
- Why is a list comprehension so much faster than appending to a list?
- Python’s most efficient way to choose longest string in list?
- List comprehension vs generator expression’s weird timeit results?
- How to unzip a list of tuples into individual lists? [duplicate]
- list() uses slightly more memory than list comprehension
- Appending item to lists within a list comprehension
- How to frame two for loops in list comprehension python
- How to return a subset of a list that matches a condition [duplicate]
- Python using enumerate inside list comprehension
- Nested list comprehensions
- How to remove multiple items from a list in just one statement?
- List with duplicated values and suffix
- list.extend and list comprehension [duplicate]
- Comprehension on a nested iterables?
- remove None value from a list without removing the 0 value
- How can I use list comprehensions to process a nested list?
- sum each value in a list of tuples
- flatten list of list through list comprehension
- Converting List Comprehensions to For Loops in Python
- Optimal method to find the max of sublist items within list
- Skip elements on a condition based in a list comprehension in python