Function with list of strings as parameter, that appends the lists contents in reverse order | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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."

31st Mar 2018, 1:00 AM
Taylor Deal
Taylor Deal - avatar
2 Answers
+ 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.
2nd Apr 2018, 2:49 PM
Taylor Deal
Taylor Deal - avatar
+ 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
11th Apr 2018, 12:18 PM
Luis Gonzalez
Luis Gonzalez - avatar