Python - Problema con matriz

 
Vista:

Problema con matriz

Publicado por rashid (8 intervenciones) el 14/02/2022 22:44:25
Como puedo mostrar los caracteres randomizados en llistes() cuando imprimo la tabla que en vez de que salga none salga los caracteres dentro.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import random
matriu=[]
matriu2=[]
llista2=[]
llista=["!","/","-","$","&","*","¿","%","(",")","·","ç","=","<",">","]","a","b"]
M=int(input("Escriu la mida del tauler: "))
def llistes():
    global llista,llista2
    for i in range(0,int((M*M)/2)):
        llista2.append(llista[i])
    llista2 = llista2 * 2
    llista2 = random.sample(llista2,M*M)
 
    print(llista2)
def omplirMatriu():
    for i in range(M+2):
        matriu.append([])
        for j in range(M+2):
            matriu[i].append(llistes())
def mostrarMatriu():
    for i in range(M+2):
        for j in range(M+2):
            print(matriu[i][j], end =" ")
        print()
llistes()
omplirMatriu()
mostrarMatriu()
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder