s = 'one two one two one'
print(s.replace(' ', '-'))
# Output -
# one-two-one-two-one
s = 'one two one two one'
print(s.replace(' ', ''))
# Output -
# onetwoonetwoone
# plz suscribe to my youtube channel -->
# https://www.youtube.com/channel/UC-sfqidn2fKZslHWnm5qe-A
text = "python is too difficult , I have a good experience with it"
#python is too difficult I am using this text for example only
print(text.replace('difficult', 'easy'))
#####output#####
#python is too easy , I have a good experience with it
# Replace a particular item in a Python list
a_list = ['aple', 'orange', 'aple', 'banana', 'grape', 'aple']
for i in range(len(a_list)):
if a_list[i] == 'aple':
a_list[i] = 'apple'
print(a_list)
# Returns: ['apple', 'orange', 'apple', 'banana', 'grape', 'apple']
s = 'Some String test'
print(s.replace(' ', '-'))
# Output
# Some-String-test
s1 = 'The theory of data science is of the utmost importance.'
s2 = 'practice'
print('The new sentence: {}'.format(s1.replace('theory', s2)))
# Ouput
# The new sentence: The practice of data science is of the utmost importance.