1
matriz = []
def create_matriz(a, b):
for contador in range(a):
matriz.append( [0] * b )
def print_matriz(txt):
cont = 0
for j in range(a):
for i in range(b):
if txt[cont] == "0":
matriz[i][j] = 0
elif txt[cont] == "1":
matriz[i][j] = 1
print txt[cont]
cont += 1
code = " #Aqui vai uma sequência de 441(21 x 21) algarismos zeros e uns/Não
coloquei porque da problema"
a = 21
b = 21
create_matriz(a, b)
print_matriz(code)
Next, I have this code to read a string with 441 digits, and put them inside an integer matrix.
So far so good.
But when printing, instead of printing as a matrix (no line break), for each of the 441 digits, print a new line.
How do I not break line and print a picture with dimensions 21 x 21?
ex:
000000000000000000000
110111011111011111110
010101000100010100010
010101111111010101110
010100000101000101000
011101111101110101110
000001010100010100010
011111010111011101010
000000010001000001010
011111010111011111010
010100010000010101000
010111110111110101110
010000000100000000010
010111110101110111110
010101010101010100000
010101011101010111010
010101000001010001010
010101011111011111010
010001010000000000010
011111011111111111111
000000000000000000000
This is the right way. Even better if the program is made in Python 3 - the latest version of Python 2. - the 2.7, was made in 2010 - and none of the language enhancements has since been incorporated into Python 2.
– jsbueno