This is a good usage of list comprehension – its also the most readable way to do it IMO.
So the [[] for x in range(0,3)]
you suggest isn’t the multiplication operator, but gets the result you want.
More Related Contents:
- What does += mean in this context?
- How to name a file using a value in a list in a dictionary?
- What does “list comprehension” and similar mean? How does it work and how can I use it?
- Why does append() always return None in Python? [duplicate]
- Convert all strings in a list to int
- Get unique values from a list in python [duplicate]
- Element-wise addition of 2 lists?
- Iterate over all pairs of consecutive items in a list [duplicate]
- How Big can a Python List Get?
- Sum a list of numbers in Python
- List comprehension vs generator expression’s weird timeit results?
- Modify a list while iterating
- How do I create a list with numbers between two values?
- How do I loop through a list by twos? [duplicate]
- How to merge multiple lists into one list in python? [duplicate]
- django – convert a list back to a queryset [duplicate]
- How to convert a string of space- and comma- separated numbers into a list of int? [duplicate]
- Convert list of strings to dictionary
- Sort list of strings by a part of the string
- How to remove multiple items from a list in just one statement?
- Create random list of integers in Python
- Write and read a list from file
- How to flatten a tuple in python
- Why does df.apply(tuple) work but not df.apply(list)?
- How to concatenate element-wise two lists in Python [duplicate]
- Identify duplicate values in a list in Python
- Turning a list into nested lists in python
- Python list slice syntax used for no obvious reason
- Creating a dictionary with list of lists in Python
- Nested lambda statements when sorting lists