Printing a matrix in an iconic memory experiment

hello everyone,
i’m coding an experiment that checks the iconic memory of the participants, i will do this by showing them a randomly generated 3*3 matrices of numbers, letters and polygons and i need to print them, in the following code that i made that does exactly what i explained earlier i’m facing the problem of how i can print the matrices on the experiment screen since the “print” command just print them in the runner screen. i tried diffrent ways that i found but it’s not really working…
thank you very much for your help and have a nice day :slight_smile:

here is the code:

import numpy as np
from random import random, choice

def create_matrix(letters, numbers, polygons):
“”“Creates a 3x3 matrix with random elements from the given lists.”“”
matrix = np.zeros((3, 3), dtype=object)
for i in range(3):
for j in range(3):
matrix[i][j] = np.random.choice(letters + numbers + polygons)
return matrix

def main():
“”“Creates 100 different 3x3 matrices.”“”
letters = [chr(i) for i in range(65, 91)]
numbers = [str(i) for i in range(10)]
polygons = [“square”, “circle”, “triangle”]
seen_matrices = set()
MyList=[letters, numbers, polygons]
for i in range(100):
l = choice(MyList)
MyList.remove(l)
g = choice(MyList)
MyList.remove(g)
x = choice(MyList)
MyList.remove(x)
matrix = create_matrix(l, x, g)
matrix_tuple = tuple(matrix.flatten())
if matrix_tuple in seen_matrices:
i -= 1
continue
seen_matrices.add(matrix_tuple)
MyList=[letters, numbers, polygons]
print(matrix)

if name == “main”:
main()

again thank you so much!

Do you have any code to create the visual objects?

You might find my points on a grid online demo useful, since it can be used to create grids of text, images, polygons or shapes. It uses Builder but the objects are created in code components.