Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Matrix Transpose using Nested Loop

# Program to transpose a matrix using a nested loop

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

result = [[0,0,0],
         [0,0,0]]

# iterate through rows
for i in range(len(X)):
   # iterate through columns
   for j in range(len(X[0])):
       result[j][i] = X[i][j]

for r in result:
   print(r)
Comment

PREVIOUS NEXT
Code Example
Python :: Python Program to Display Powers of 2 Using Anonymous Function 
Python :: Bilgisayardaki mp3 uzantili dosyalari bulma 
Python :: how to use kite python 
Python :: how to reorder columns in pandas 
Python :: python map and filter 
Python :: check if variable is iterable python 
Python :: Django forms I cannot save picture file 
Python :: pyqt5.direct connection 
Python :: function print(text, times) 
Python :: reddit python 3 time a python program 
Python :: pyqt stretch image 
Python :: how to write flow of execution in python 
Python :: File "demo_indentation_test.py", line 2 print("Five is greater than two!") ^ IndentationError: expected an indented block 
Python :: if len(i1.getbands()) == 1 
Python :: pyAesCrypt 
Python :: python code to display a grid of data table 
Python :: pyqt5 messagebox settext 
Python :: Tape Equilibrium 
Python :: Syntax Closing a File in python 
Python :: Python Using Global and Local variables in the same code 
Python :: python reverse list every 2 element 
Python :: Pandas dataframe with MultiIndex: check if string is contained in index level 
Python :: sklearn standardscaler for numerical columns 
Python :: fetchall in python sqilite3 
Python :: Python RegEx re.compile() Set class [s,.] will match any whitespace character ‘,’ or ‘.’ 
Python :: sample regression algorithm using pipeline with hyperparameter tuning 
Python :: django chain query 
Python :: print command in python 
Python :: how to choose appropriate graph for dataset visualization 
Python :: change label in dataframe per condition 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =