0

Given the string “To dance or not to dance”, have the program replace all occurances of the word “dance” with “be”.

My attempt but its having error

    word = "To dance or not to dance"
    replaceWords = str_replace("dance","be", word)
    print (replaceWords)
i'm sorry
  • 53
  • 5

2 Answers2

1

I think this can work.

word = word.replace("dance","be")
1
new_word=word.replace("dance", "be")