-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprogram3.py
More file actions
29 lines (18 loc) · 751 Bytes
/
program3.py
File metadata and controls
29 lines (18 loc) · 751 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
# write a program to demonstrate at least six strings operations including split,search,join,modify
string = "Hello, world!"
words = string.split()
print("Splitting the string into words:", words)
substring = "world"
if substring in string:
print("Substring found in the string.")
string1 = "good"
string2 = "day"
joined = string1 + string2
print("Joining the list of words into a string:", joined)
new_string = string.replace("world", "Python")
print("Modifying the string by replacing a substring:", new_string)
uppercase_string = string.upper()
print("Converting the string to uppercase:", uppercase_string)
stripped_string = string.strip()
print("Removing whitespace from the string:", stripped_string)
print(string.find("world"))