Code gone wrong

I am getting the right answer in sublime text but not in launchpad. pls check.

you are not printing output according to question:
your output:
Screenshot 2022-08-21 at 1.31.35 PM

correct output:
Screenshot 2022-08-21 at 1.29.35 PM

i have resolved your mistake in below modified code,
i put comments on this to better under stand
and try to dry this modified code your doubt get resolved

Modified code : https://ide.codingblocks.com/s/671455

i hope this help, if you have further doubt
please feel free to ask