#python #anaconda #jupyter-notebook #visual-code #html #css #javascript #http

제목[re]List 질문2021-10-17 21:24
작성자

안녕하세요.


해당 문제는 list도 object로, 동일한 메모리를 사용하기 때문입니다.


즉 student1,2,3은 서로 다른 메모리를 사용하지만, 그 안에 있는 ['python',94]는 하나의 메모리(a) 위에 있고, student1,2,3 모두 a를 사용하게 됩니다.


따라서 복제를 하고 싶다면 copy 모듈의 deepcopy를 사용하면 됩니다. 아래 글을 참고하시면 좋을 것 같습니다.


https://levelup.gitconnected.com/understanding-reference-and-copy-in-python-c681341a0cd8

댓글
이전List 질문2021-10-17
다음반환과 print의 차이2021-10-15