-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathS05L23_script01.py
More file actions
47 lines (28 loc) · 930 Bytes
/
Copy pathS05L23_script01.py
File metadata and controls
47 lines (28 loc) · 930 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
45
46
47
# for testing methods
a = "hello"
b = "happy biRthday"
print("original a:" "{}".format(a))
print("original b:" "{}".format(b))
# Example of methods
# Count method
print(a.count("e"))
print(b.count("day"))
# lower method
print(b.lower())
# upper method
print(b.upper())
# capitalize method (just uppercase the first letter)
print(a.capitalize())
# title method (capitalize every word in the string)
print(b.title())
# islower and isupper methods (will check if the whole text is in lowercase/uppercase)
print(b.islower())
print(b.isupper())
# istitle method similar like isupper but just for the words first letter
print(a.istitle())
# isalpha checks if the string contains only letters (spaces are not inlcluded !!)
print(a.isalpha())
# isdigit check if the string only contains numbers
print(a.isdigit())
# isalnum check if the string contains combinations of number of leters
print("12cacaeWEe".isalnum())