forked from MorvanZhou/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path35_set.py
More file actions
26 lines (18 loc) · 675 Bytes
/
35_set.py
File metadata and controls
26 lines (18 loc) · 675 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# View more python learning tutorial on my Youtube and Youku channel!!!
# Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg
# Youku video tutorial: http://i.youku.com/pythontutorial
char_list = ['a', 'b', 'c', 'c', 'd', 'd', 'd']
sentence = 'Welcome Back to This Tutorial'
print(set(char_list))
print(set(sentence))
print(set([char_list, sentence]))
unique_char = set(char_list)
unique_char.add('x')
unique_char.add(['y', 'z'])
print(unique_char)
unique_char.clear()
print(unique_char)
print(char_list.discard('d'))
print(char_list.remove('d'))
print(char_list.difference({'a', 'e', 'i'}))
print(char_list.intersection({'a', 'e', 'i'}))