-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsets.py
More file actions
44 lines (26 loc) · 751 Bytes
/
sets.py
File metadata and controls
44 lines (26 loc) · 751 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Sets = Unorderd, Unindexed, Unique, uneditable
# fruit = {"Apple", "Banana", "Mango", "Blackberry"}
# Accessing
# for x in fruit:
# print(x)
# Add to Set
# fruit = {"Apple", "Banana", "Mango", "Blackberry"}
# fruit.add("Orange")
# print(fruit)
# Add multiple items
# fruit = {"Apple", "Banana", "Mango", "Blackberry"}
# fruit.update(["Grapes", "Orange", "Strawberry"])
# print(fruit)
#Remove Item
# fruit = {"Apple", "Banana", "Mango", "Blackberry"}
# fruit.remove("Banana")
# fruit.discard("orange")
# fruit.pop()
# fruit.clear()
# print(fruit)
# How to combine two sets
# fruit = {"Apple", "Banana", "Mango", "Blackberry"}
# fruit2 = {"Orange", "Banana"}
# # fruit3 = fruit.union(fruit2)
# fruit.update(fruit2)
# print(fruit)