Please correct the code

Hello @Lovishbansal,

I have corrected your code:


Refer to the comments for better understanding.

Hope, this would help.
Give a like if you are satisfied.