programming-examples/python/String/Python function to insert a string in the middle of a string.py

6 lines
218 B
Python
Raw Normal View History

2019-11-15 12:59:38 +01:00
def insert_sting_middle(str, word):
return str[:2] + word + str[2:]
print(insert_sting_middle('[[]]', 'Python'))
print(insert_sting_middle('{{}}', 'PHP'))
print(insert_sting_middle('<<>>', 'HTML'))