Explica este c贸digo Python
Dificultad: Intermedio
def f(text, target_word, replace_word):
index_target_word = text.find(target_word)
x = text[0:index_target_word]
y = text[index_target_word + len(target_word):len(text)]
return f"{x}{replace_word}{y}"
print(f("Keep calm and write Python", "write", "enjoy"))
馃憠 A. Keep calm and write Python
馃憠 B. Keep calm and enjoy Python
馃憠 C. IndexError
馃憠 D. TypeError
馃憠 B. Usando Respuesta:
Keep calm and enjoy Python
La funci贸n f
implementa un algoritmo para buscar y remplazar una palabra dada por otra sin el uso de la funci贸n replace
de Python. find()
y dividiendo la cadena podemos lograr lo que se pretende.