[ANSWERED] Anomaly with implementation of algorithm for reversing a number (integer)
Hi SoloLearners, It all started as I read this post https://www.sololearn.com/Discuss/3064986/?ref=app - asking how to reverse a number (integer). I understand this could be easy in Python should we choose to convert the number to string and reverse the string instead. I also have a little idea how to deal with negative sign, still in regards to using string version of the number. I have learned how a number is reversed using loop, modulo and division, and it works just fine disregarding whether number was positive or negative. But my attempt to implement the same logic in Python is failing me on negative numbers. The loop goes infinite when the number was negative. The ultimate question is, why this logic works perfectly fine in C/C++ (and some others I guess) yet it's glitching in Python. Please enlighten me And Thank you in advance 🙏 https://code.sololearn.com/cNLi6Xs9Wlu9/?ref=app https://code.sololearn.com/criN8639x744/?ref=app