The trick to reverse a number is probably awfully slow.<p><pre><code> print(int(str(num)[::-1]))
</code></pre>
Unless the Python compiler has a huge bigger amount of magic than what I imagine is possible, this code is very slow.<p>It's not so bad if you run it once, but if you put it inside a thigh loop, the performance would be awful. Never ever use a string to transform a number into another number in any language.<p>Perhaps you can try to make a post with a benchmark comparing this method and another method that only use integer division (and perhaps other that use floating point division).