0

I working on a project to correct grammatically wrong sentence to correct one. How do I use python to replace the word in between 2nd and 3rd space to the correct one?

I need the search for what to replace to be the position not search for exact word and replace it.

S = "Nothing is absolute right or wrong ."

Position -> 2 and 3 (this position is the position of space to replace the word between 2nd space and 3rd space)
Replace "absolute" with "absolutely" 

mujjiga
  • 16,186
  • 2
  • 33
  • 51
sirimiri
  • 509
  • 2
  • 6
  • 18
  • 1
    your used tags has nothing to do with your question. Also you should show your own approach. If you hadnt any idea, maybe try a look [here](https://stackoverflow.com/questions/66598947/how-to-make-translating-function-in-python) – Doluk Mar 13 '21 at 07:22
  • 1
    Why use "|||" as the separator instead of just "|"? – Tim Roberts Mar 13 '21 at 07:30
  • the dataset i found online use ||| as separator, so I have to work with this – sirimiri Mar 13 '21 at 07:30
  • 1
    You can picture what has to be done, right? Read the first string. Use `words = s.split()` to divide it into words. Use `words[position] = replacement` to fix it. Use `' '.join(words)` to build the new sentence. – Tim Roberts Mar 13 '21 at 08:05
  • 1
    take a look at this https://stackoverflow.com/a/66605152/7865368 – Vishal Singh Mar 13 '21 at 08:19

0 Answers0