Search code examples
pythonpython-3.xreverse

Reverse of number of integer inputs


enter_inputs=int(input())
for i in range(enter_inputs):
   rev=0
   while i>0:
       rev=(rev*10)+i%10
       i=i//10
   print(rev)

I am trying to get the reverse of a number in python but I am getting EOFError: EOF when reading a line why?

I guess my logic is correct.


Solution

  • You are using using Python Man!, There would be inbuilt-functions for these basic uses.

    number = int(input())
    print(int(str(number)[::-1]))