Hello Please help (Python)

I am new to programming, I am getting an error however it is showing correct output in IDLE.
I can’t figure out where I made an error
This is the problem
Problem
And this is my submission
My submission
Please help
Thanks in advance

Follow this Code
your approach is wrong… please go through the code and read it(did some little changes in your code)…