Algorithm/ํ์ด์ฌ ์ฝ๋ฉํ
์คํธ
์๋ฃ๊ตฌ์กฐ ํ์ฉ (ํ) - 7. ๊ต์ก๊ณผ์ ์ค๊ณ
hello_u
2023. 2. 4. 17:53

๋์ ํ์ด

#์ฐธ๊ณ
>>> list1 = [1, 2, 3, 4]
>>> list2 = list1
>>> print(list1)
[1, 2, 3, 4]
>>> print(list2)
[1, 2, 3, 4]
list2๋ list1์ ๋ฉ๋ชจ๋ฆฌ ์ฃผ์๊ฐ์ ๋ณต์ฌํ ๊ฒ์ด๋ค.
์ฆ, ๊ฐ์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ฐธ์กฐํ๊ธฐ ๋๋ฌธ์ list1์ด ์์ ๋๋ฉด list2๋ ๋์์ ์์ ๋๋ค.

list1์ list2์ด ์๋ก ๋ค๋ฅธ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ฐธ์กฐํ๋๋ก ํด์ฃผ๋ฉด ๋๋ค.
ํ์ด์ฌ ๋ฆฌ์คํธ๋ฅผ ๋ค๋ฅธ ๋ฆฌ์คํธ์ ๋ณต์ฌํ๋ ๋ฐฉ๋ฒ์ 4๊ฐ์ง๊ฐ ์๋ค.

๊ฐ์ ํ์ด
