set

Published by onesixx on

https://codingwanee.tistory.com

순서(인덱싱), 중복이 없다.

mySet = set("Hello")        # 중복불가라 l은 없어짐.
# {'H', 'e', 'l', 'o'}


s1 = set('123')
s2 = set('345345')

# 합집합
s1|s2
s1.union(s2)
# {'1', '2', '3', '4', '5'}

# 교집합
s1&s2
s1.intersection(s2)
# {'3'}

# 차집합
s1-s2
s1.difference(s2)
# {'1', '2'}

인덱싱이 필요하면 list / tuple로 형변환

Categories: Python Basic

onesixx

Blog Owner

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x