-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrings.py
More file actions
49 lines (38 loc) · 983 Bytes
/
strings.py
File metadata and controls
49 lines (38 loc) · 983 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
48
49
""""
This module practice working with string data type
"""
message = 'Hello, World!'
some_text = "Bobby's World"
multiline_text = """Bobby's World is the name of animation
at the end of 1990's."""
# Formatted String
print("{}. {}".format(some_text, multiline_text))
print(f"{some_text}. {multiline_text}")
replaced_message = message.replace('World', 'Universe')
print(message)
print(type(message))
print(len(message))
# Some methods of str object
print(message.lower())
print(message.upper())
print(message.capitalize())
print(message.count('He'))
print(message.count('l'))
print(message.count('universe'))
print(message.find('World'))
print(replaced_message)
# Indexing
print(message[0])
print(message[12])
print(message[-1])
# Slicing
print(message[:4])
print(message[6:])
print(message[::-1])
# Show all methods of an object
print(dir(message))
# Show Documentation Help of anything
# print(help(str))
print(help(str.translate))
print(some_text)
print(multiline_text)