Consider the following two-dimensional list:
original = [[1, 2], [3, 4]]
Lets break it down step by step:
>>> original[::-1] # elements of original are reversed [[3, 4], [1, 2]]
This list is passed into zip()
using argument unpacking, so the zip
call ends up being the equivalent of this:
zip([3, 4], [1, 2]) # ^ ^----column 2 # |-------column 1 # returns [(3, 1), (4, 2)], which is a original rotated clockwise
Hopefully the comments make it clear what zip
does, it will group elements from each input iterable based on index, or in other words it groups the columns.
Related Posts:
- How to make a flat list out of a list of lists
- What is the purpose of meshgrid in Python / NumPy?
- How does numpy.newaxis work and when to use it?
- How to count the occurrence of certain item in an ndarray?
- How to initialize a two-dimensional array in Python?
- How to initialize a two-dimensional array in Python?
- Create 3D array using Python
- How to have an array of arrays in Python
- Two dimensional array in python
- Understanding NumPy’s einsum
- Iterating over a 2 dimensional python list [duplicate]
- Good ways to “expand” a numpy ndarray?
- Using numpy to build an array of all combinations of two arrays
- Convert a 1D array to a 2D array in numpy
- How do I lowercase a string in Python?
- Difference between del, remove, and pop on lists
- How to use the pass statement
- How do you round UP a number?
- How do I update\upgrade pip itself from inside my virtual environment?
- ImportError: DLL load failed: The specified module could not be found
- Replacements for switch statement in Python?
- Correct way to write line to file?
- How to read a file line-by-line into a list?
- How do I sort a dictionary by value?
- What does %s mean in a python format string?
- Redirecting to URL in Flask
- TypeError: ‘float’ object is not callable
- Plotting a 2D heatmap with Matplotlib
- Purpose of __repr__ method?
- json.dumps vs flask.jsonify
- How to print like printf in Python3?
- “Defaulting to user installation because normal site-packages is not writeable” python message
- How to install pytorch in Anaconda with conda or pip?
- How can I remove a key from a Python dictionary?
- What does numpy.random.seed(0) do?
- How do I check if a variable exists?
- Is there a label/goto in Python?
- Why do I get “Pickle – EOFError: Ran out of input” reading an empty file?
- Getting TypeError: __init__() missing 1 required positional argument: ‘on_delete’ when trying to add parent table after child table with entries
- Django: ImproperlyConfigured: The SECRET_KEY setting must not be empty
- builtins.TypeError: must be str, not bytes
- How do you read from stdin?
- takes 1 positional argument but 2 were given
- What is dtype(‘O’), in pandas?
- Call a function from another file?
- What’s the difference between %s and %d in Python string formatting?
- What is the difference between Jupyter Notebook and JupyterLab?
- Python 3 ImportError: No module named ‘ConfigParser’
- How does Python’s super() work with multiple inheritance?
- How can the Euclidean distance be calculated with NumPy?
- Tkinter understanding mainloop
- Embedding in pytorch
- Check string “None” or “not” in Python 2.7
- re.search().TypeError: cannot use a string pattern on a bytes-like object
- Why am I getting a FileNotFoundError?
- Anaconda Navigator won’t launch (windows 10)
- What are all possible pos tags of NLTK?
- Can’t open Jupyter notebook with Anaconda
- How to change dataframe column names in pyspark?
- Pickle , read in data , unsupported pickle protocol: 3 python 2.7
- pygame clock.tick() vs framerate in game main loop
- Use of “global” keyword in Python
- Convert a Pandas DataFrame to a dictionary
- Python: Write array values into file
- use np.random.multinomial() in python
- How to implement a binary search tree in Python?
- TypeError: cannot unpack non-iterable NoneType object
- Search and replace a line in a file in Python
- Can’t import my own modules in Python
- What are the most common Python docstring formats?
- How do I install a pip package globally instead of locally?
- Python Array Rotation
- standard_init_linux.go:178: exec user process caused “exec format error”
- How to find char in string and get all the indexes?
- How can I create an array/list of dictionaries in python?
- How to unnest a nested list
- How to sort a list/tuple of lists/tuples by the element at a given index?
- How do I make a dictionary with multiple keys to one value?
- Directing print output to a .txt file
- How to add pandas data to an existing csv file?
- Can sklearn random forest directly handle categorical features?
- What are the differences between numpy arrays and matrices? Which one should I use?
- Use different Python version with virtualenv
- Print empty line?
- pandas groupby sort within groups
- Python Socket Receive Large Amount of Data
- How to find out whether a file is at its `eof`?
- TypeError: Image data can not convert to float
- coercing to Unicode: need string or buffer, NoneType found when rendering in django admin
- Convert from ASCII string encoded in Hex to plain ASCII?
- Simple way to create matrix of random numbers
- pandas: multiple conditions while indexing data frame – unexpected behavior
- How can I tail a log file in Python?
- How to write unicode strings into a file?
- python-How to set global variables in Flask?
- How do I install pip on macOS or OS X?
- NameError: name ‘get_ipython’ is not defined
- Equivalent to matlab’s imagesc in matplotlib? [duplicate]
- bash: syntax error near unexpected token `(‘ – Python
- Find all files in a directory with extension .txt in Python