-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_demo3.py
More file actions
40 lines (33 loc) · 870 Bytes
/
set_demo3.py
File metadata and controls
40 lines (33 loc) · 870 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
def demo_loop():
s = {"apple", "banana", "mango", "cherry"}
a = list(s)
a.sort()
for f in a:
print(f)
def demo_loop2():
countries = {
("th", "Thailand"),
("jp", "Japan"),
("kr", "Korea")
}
# print(countries)
# for c in countries:
# print(c[0])
# for country_id, country_name in countries:
# print(country_name)
for i, (country_id, country_name) in enumerate(countries):
print("{}. {} {}".format(i + 1, country_id, country_name))
if ("jp", "Japan") in countries:
print("found")
else:
print("not found")
def immutable_set():
# frozenset ไม่สามารถแก้ไขได้
fz = frozenset(["lily", "carnation"])
print(fz)
print(type(fz))
fz.add("ivy")
print(fz)
# demo_loop()
# demo_loop2()
immutable_set()