Johanna Sanchez Vallejo
EstudiantePreguntaDiferentes formas de copiar una lista
Este hilo detalla las formas de copiar una lista
++Copy the list, you have various possibilities:
++
- You can use the builtin list.copy() method (available since python 3.3):
new_list = old_list.copy()
- You can slice it:
new_list = old_list[:]
- You can use the built in list() function:
new_list = list(old_list)
- You can use generic copy.copy():
import copy new_list = copy.copy(old_list)
- If the list contains objects and you want to copy them as well, use generic copy.deepcopy():
import copy new_list = copy.deepcopy(old_list)
Guillermo García López
EstudianteGran aporte gracias.
Alexander Román
Estudiante:o
Pablo Aquino
EstudianteExcelente, de los resultados la manera más optima, en cuanto a tiempo, es la de slices.
Omar Daniel Centeno
EstudianteGenial!
Omar Rodríguez Aldama
Estudiantebeunisimo el aporte
