How to insert a string into given string before specific word in Python

1 Answer

0 votes
s = 'python java c++'

index = s.find('java')

s = s[:index] + 'c ' + s[index:]

print(s)

 
 
 
'''
run:
 
python c java c++

'''

 



answered Aug 31, 2021 by avibootz

Related questions

...