Nested If Python Program For Reverse