-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringPractice.py
More file actions
59 lines (42 loc) · 1.07 KB
/
StringPractice.py
File metadata and controls
59 lines (42 loc) · 1.07 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""s = input("input Python source code name :")
if s.endswith(".py"):
print("Good")
else:
print("Bad") """
s = "www.naver.com"
print(s.replace("com", "co.kr"))
s = "www.naver.co.kr"
print(s.find(".kr"))
s = "Let it be, let it be, let it be"
print(s.rfind("let"))
s = "www.naver.co.kr"
print(s.count("."))
s = " Hello, World! "
print(s.strip())
s = "######this is example######"
print(s.strip("#"))
s = "######this is example######"
print(s.lstrip("#"))
print(s.rstrip("#"))
s = "Welcome to python"
print(s.split())
s = "Hello, World!"
print(s.split(","))
email = "kskslr@naver.com"
print(email.split("@"))
print(",".join(["apple", "banana", "cherry"]))
print("-".join("010.2326.5569".split(".")))
address = input("Enter your address: ")
id, domain = address.split("@")
print("ID: ", id)
print("Domain: ", domain)
sentence = input("input String:")
table = {"alpha":0, "digit":0, "space":0}
for i in sentence:
if i.isalpha():
table["alpha"] += 1
elif i.isdigit():
table["digit"] += 1
elif i.isspace():
table["space"] += 1
print(table)