Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Matrix Transpose using Nested List Comprehension

''' Program to transpose a matrix using list comprehension'''

X = [[12,7],
    [4 ,5],
    [3 ,8]]

result = [[X[j][i] for j in range(len(X))] for i in range(len(X[0]))]

for r in result:
   print(r)
Comment

PREVIOUS NEXT
Code Example
Python :: Source Code: Check Armstrong number (for 3 digits) 
Python :: Random parola uretme 
Python :: geodataframe and geoseries 
Python :: what is flash in flask 
Python :: python array to text 
Python :: python solve rubicks cube 
Python :: clustermap subplots 
Python :: preventing players from changing existing entries in tic tac toe game 
Python :: signup generic 
Python :: how to preserve white space when joining an array python 
Python :: cv2 put font on center 
Python :: download face_cascade.detectMultiScale 
Python :: command run test keep db python 
Python :: cudf - merge dataframes 
Python :: truc python 
Python :: validate delete inline formset django 
Python :: pyqt message box set detailed text 
Python :: CNN Libraries 
Python :: Python Write to File Way01 
Python :: Python Global variable and Local variable with same name 
Python :: python empty list boolean 
Python :: How to deal with SettingWithCopyWarning in Pandas 
Python :: pyspark percentage missing values 
Python :: python check if array alternating 
Python :: python regex compile 
Python :: disable gpu in jupyter notebook 
Python :: python split get array for loop 
Python :: bold colors in pytohn 
Python :: appropriate graph for dataset visualization 
Python :: django error column last_login cannot be null 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =