(Answering the title, because the rest did not understand anything, please edit and improve the question)
From a list, we can concatenate its values in various ways such as:
lista = ['o','l','a']
string = ''.join(lista)
string = ''.join([x for x in lista])
string = ''.join(map(lambda x: x, lista))
def concatena(lista):
string = ''
for x in lista:
string += x
return string
string = concatena(lista)
>>> print(string)
ola
And we can even modify if necessary:
string = ''.join([x.upper() for x in lista]) #ou .lower()
Complicating a little, but not too much, we can play with matrices. Now just take the matrix lists and apply a method above.
matriz = [['o'],['l'],['a']]
#string = ''.join(map(lambda lista: Algum_metodo_acima, matriz))
#string = ''.join([Algum_metodo_acima for lista in matriz])
string = ''.join(map(lambda lista: ''.join(lista), matriz))
string = ''.join([''.join(lista) for lista in matriz])
def concatena_matriz(matriz):
string = ''
for lista in matriz:
for x in lista:
string += x
return string
string = concatena_matriz(matriz)
>>> print(string)
ola
It is a question ? If yes what is the question ? The code does not work ? It does not do what is expected ? It gives error ?
– Isac
List
[['a'], ['b']]
or matrix[['a'], ['b']]
?– AlexCiuffa