134. String Maketrans and Partition Method in Python with Example Code || Python String Methods-16

Published: 04 October 2022
on channel: Bhavatavi
8
0

Code:
dict={'a':'123','b':'456','c':'789'}
string='abc'
print(string.maketrans(dict))

dict={97:'123',98:'456',99:'789'}
string='abc'
print(string.maketrans(dict))

#Translational table using two string

firstString='abc'
secondString='def'
string='abc'
print(string.maketrans(firstString,secondString))

#Translational table using removable string

firstString='abc'
secondString='def'
thirdString='abd'
string='abc'
print(string.maketrans(firstString,secondString,thirdString))

#partition

string='Python is fun'
print(string.partition('is '))

print(string.partition('not '))

string="Python is fun, isn't it"

print(string.partition('is'))


On this page of the site you can watch the video online 134. String Maketrans and Partition Method in Python with Example Code || Python String Methods-16 with a duration of online in good quality, which was uploaded by the user Bhavatavi 04 October 2022, share the link with friends and acquaintances, this video has already been watched 8 times on youtube and it was liked by 0 viewers. Enjoy your viewing!