Set, Dictionary, List, Tuple

박광수·2022년 3월 5일
0

Set vs Dictionary

  • Set은 Key값만 있다. vs Dictionary는 Key : Value 값이 있다.
  • Set : mutable vs Dictionary : (Key : immutable), (Value : mutable)

List vs Tuple

  • list 는 [] 사용 vs Tuple 은 () 사용
  • list : mutable vs Tuple : immutable

(참고) Mutable, Immutable

  • mutable이란 값이 변한다는 뜻이고, immutable은 변하지 않는다는 뜻이다.

  • list : mutable

x=[1,2]
y=x
y.append(3)
print (x)
print (y)

[1, 2, 3]
[1, 2, 3]

  • tuple: immutable
x=(1,2)
y=x
y+=(3,)
print (x)
print (y)

(1, 2)
(1, 2, 3)

profile
박광수입니다.

0개의 댓글

관련 채용 정보