-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrings.py
More file actions
48 lines (36 loc) · 1.36 KB
/
strings.py
File metadata and controls
48 lines (36 loc) · 1.36 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
multiLine_str_tripleQuotation = """"Lorem ipsum dolor sit amet,
consectetur adipiscing elit,
sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua."""
print(multiLine_str_tripleQuotation[0:6])
print(multiLine_str_tripleQuotation[-23:-1])
print("length is =", len(multiLine_str_tripleQuotation))
print("one line", "two line", sep="-----") #one line-----two line
stripMethod = " hello "
print(stripMethod.strip())#removes spaces
lowerMethod = "hELLo UnIvERse"
print(lowerMethod.lower())#returns lower cases
upperMethod = "these are capital letters"
print(upperMethod.upper())#returns capitals
replaceMethod = "Replace me with yo"
print(replaceMethod.replace("me","yo"))
splitMethod = "hello - universe"
print(splitMethod.split(","))
#method splits the string into subtstrings if it
#finds instances of the separator
checkIfTxt = 'Check if the wapa is in text'
checkFunc = "wapa" in checkIfTxt
print(checkFunc, ": The word wapa is in")
check_if_not_in_text = "is the word poopy in this string"
checkIf_not_func = "poopy" not in check_if_not_in_text
print(checkIf_not_func,": The word poopy is not in")
hello = "hello "
world = "world"
print(hello+world)
mixedMethods = " HelLoRZsS "
print(mixedMethods.lower().strip().split())
arrow_str = "<-----"
arrow_str1 = "----->"
print(arrow_str+" + "+arrow_str1)
if __name__ == '__main__':
print ("Hello, World!")