Replace all pie

I am not getting the desired output, what is the mistake here ?

Hi @abhishekjohri98,
There were some errors . I have corrected and wrote what they were in comments in the following code.