-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring_method3.py
More file actions
31 lines (26 loc) · 888 Bytes
/
string_method3.py
File metadata and controls
31 lines (26 loc) · 888 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
import random
def join_demo():
stations = ("HUA", "SAM", "SIL", "LUM", "KHO", "SIR",
"SUK", "PET", "RAM", "CUL", "HUI", "SUT",
"RAT", "LAT", "PHA", "CHA", "KAM", "BAN")
print(stations)
print(" -> ".join(stations))
print(" -> ".join(stations[1:4]))
print(" -> ".join(stations[1:4][::-1]))
def password_generator(length):
# s = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
# print(s)
# p = random.sample(s, length)
# print(p)
# return "".join(random.sample(s, length))
return "".join(random.sample(list("ABCDEFGHJKLMNPQRSTUVWXYZ23456789"), length))
def replace_demo():
s = "password"
s2 = s.replace("a", "@")
s3 = s.replace("a", "@").replace("o", "0")
s4 = s.replace("pass", "fail")
print(s, s2, s3, s4)
# join_demo()
# for i in range(10):
# print(password_generator(8))
replace_demo()