lundi 2 novembre 2020

How do i prevent changing multiple lists?

I have this script that should make two different lists. but instead, it changes both of them so they're the same.

from random import shuffle

my_list = [1,2,3,4]
second_list = []
shuffle(my_list)
second_list.extend(my_list)

print(my_list,second_list)

How do I prevent this from happening?




Aucun commentaire:

Enregistrer un commentaire