Skip to content

Commit b6831ef

Browse files
author
Mofan Zhou
committed
python basic 35 set
1 parent 6cab18d commit b6831ef

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

basic/35_set.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# View more python learning tutorial on my Youtube and Youku channel!!!
2+
3+
# Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg
4+
# Youku video tutorial: http://i.youku.com/pythontutorial
5+
6+
char_list = ['a', 'b', 'c', 'c', 'd', 'd', 'd']
7+
8+
sentence = 'Welcome Back to This Tutorial'
9+
10+
print(set(char_list))
11+
print(set(sentence))
12+
13+
print(set([char_list, sentence]))
14+
15+
unique_char = set(char_list)
16+
unique_char.add('x')
17+
unique_char.add(['y', 'z'])
18+
print(unique_char)
19+
20+
unique_char.clear()
21+
print(unique_char)
22+
print(char_list.discard('d'))
23+
print(char_list.remove('d'))
24+
25+
print(char_list.difference({'a', 'e', 'i'}))
26+
print(char_list.intersection({'a', 'e', 'i'})

0 commit comments

Comments
 (0)