Skip to content

Commit 116118f

Browse files
committed
added string replacing example
1 parent 0907d58 commit 116118f

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

Python-String/String-Replacing.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#Python String Replacing Demostration
2+
3+
# Python3 program to demonstrate the
4+
# use of replace() method
5+
6+
example = "Hello World"
7+
# Prints the string by replacing geeks by Geeks
8+
print(example.replace("World", "India"))
9+
10+
example = "Hello World World World"
11+
# Prints the string by replacing only 3 occurence of Geeks
12+
print(example.replace("World", "India", 2))
13+
14+
#concatenation with spliting and string
15+
example = "Spammy"
16+
example= example [:2]+'ic'+example[5:]
17+
print(example)
18+
19+
example = "Hello"
20+
example= example.replace('e','P')
21+
print(example)
22+
23+
#How to get the supported function of string
24+
print(dir(example))
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)