dev-resources.site
for different kinds of informations.
String Functions Examples
Published at
1/6/2025
Categories
python
stringfunction
payilagam
Author
poornima_ravi
Author
13 person written this
poornima_ravi
open
#1. L Strip
#2. R Strip
#3. Replace a string in a statement with another string
# L Strip
Str = input("Enter the String:")
ord_space = ord(' ')
ord_tab = ord('\t')
i = 0
right = 0
while i < len(Str):
if ord(Str[i]) != ord_space and ord(Str[i]) != ord_tab:
right = i
break
i+=1
Str = Str[right:]
print('LStrip String:',Str,end='#',sep='')
# R Strip
Str = input("Enter the String:")
ord_space = ord(' ')
ord_tab = ord('\t')
i = len(Str)-1
right = 0
while i > 0:
if ord(Str[i]) != ord_space and ord(Str[i]) != ord_tab:
right = i
break
else:
i-=1
Str = Str[:right+1]
print("#", Str, "#", sep='')
# Replace a string
#MSD --> Dhoni
#MSD is Former Indian Captain. MSD is retired. MSD plays for CSK
sen = 'MSD is Former Indian Captain. MSD is retired. MSD plays for CSK - MSD'
Key = 'MSD'
New_sen = ''
Key_Len = len(Key)
i=0
while i< len(sen):
if Key == sen[i:i+Key_Len]:
print('i',i)
New_sen = New_sen + 'Dhoni'
i+=Key_Len
else:
New_sen = New_sen + sen[i]
i+=1
print(New_sen)
payilagam Article's
30 articles in total
Python List Tutorial Day2
read article
System.out.println()
read article
Python List Tutorial
read article
String Functions Examples
currently reading
Front end day-1 (html,css)
read article
About IRC - Internet Relay Chat
read article
Python Day-29 Dictionary- Exercises, Tasks
read article
LCM & GCD of two numbers
read article
Weekend - Python Interview Questions
read article
Day14 Inheritance:
read article
Python day-28 Dictionary, Frequency of character using nested loops
read article
Objects
read article
System.out.println()
read article
Constructor
read article
Introduction
read article
Python Day-25 List functions, Tasks
read article
Day 12 Constructor in java:
read article
Day 4 - Dec 23 -->java simple program
read article
Day-5 Example for Encapsulation
read article
Day 11 Encupsulation
read article
Day 11 Today class:
read article
Day - 1 Task 1
read article
Day 10 Task:
read article
java task 3
read article
Day9 :Task2
read article
Java Constructors
read article
java task 3
read article
java 3 task
read article
java task1
read article
Python Day-23 Lists and list functions,Task
read article
Featured ones: