+ 1
Function with list of strings as parameter, that appends the lists contents in reverse order
"Write a function named mirror that accepts a list of strings as a parameter and appends the list's contents to itself in reverse order. For example, if a list named letters stores ["a", "b", "c"], the call of mirror(letters) should change it to store ["a", "b", "c", "c", "b", "a"]. Constraints: You may declare a single list as auxiliary storage."
2 odpowiedzi
+ 1
how do i get it to print the original list PLUS the reverse list added onto the end, made into one concatenated list? It keeps reversing the original list but adding 'none' to the end.
+ 1
#Lista espejo
def espejo(lista):
l=len(lista)
for i in range(l, 0, -1):
lista.append(i)
print(lista)
h=[1,2,3,4] # ejemplo
espejo(h) # llanada de la funcion
Función escrita para generar lista espejo.
Saludos