-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStrings_P9.py
More file actions
29 lines (28 loc) · 1018 Bytes
/
Strings_P9.py
File metadata and controls
29 lines (28 loc) · 1018 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
print("\n\t\t\tString Operations")
print("\t\t\t------------------")
print("1.Create")
print("2.Length")
print("3.Slice Operation")
print("4.Replace")
print("5.Exit")
while True:
m = int (input ("\nEnter Your Choice :"))
if(m == 1):
s= input ("Enter Your String :")
print("\n\tThe Given String is : ",s)
elif(m==2):
print ("\n\tLength of the given string is :",len(s))
elif(m==3):
sv=int(input("Enter the Start value :"))
ev=int(input("Enter the End value :"))
st=int (input("Enter the stride Value :"))
print ("\n\tSliced string is ",s[sv:ev:st])
elif (m ==4):
old=input("Enter the Old String to be replaced :")
new=input("Enter the new String :")
print("\n\tThe word has been replaced: ",s.replace(old, new))
elif(m==5):
print("\n\t\tExiting.....")
break
else :
print("Enter the option between 1-5")