Tell us what’s happening:
In the daily code challenge I have added some print statements to help with debugging. I see these printed only for the first test (which passes). For subsequent tests nothing is printed and the tests fail so I can’t debug the code in the console…
Your code so far
def rotate(matrix):
'''
Check array is square and the number of rows and columns
Create a new empty matrix of zeroes
Take row 1 and convert to the last (n)column
Take row 2 and convert to (n-1)th column
...
Take row n and convert to the 1st column
'''
height = len (matrix)
width = len (matrix[0])
out = [[0] * width for i in range(width)]
for pos1, row in enumerate(matrix, start=0):
# print(pos1, row)
for pos2, col in enumerate(row, start=0):
#print(pos1, pos2, col)
# push the value into the new coordinate
print (width-1-pos1, pos2, col )
out[width-1-pos1][pos2] = col
matrix = 1
return out
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36 Edg/139.0.0.0
Challenge Information:
Daily Coding Challenge - Matrix Rotate
https://www.freecodecamp.org/learn/daily-coding-challenge/2025-09-06