How to reverse int in python ? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 2

How to reverse int in python ?

How to reverse int in python ?

26th May 2021, 6:15 AM
Tiger Coder
Tiger Coder - avatar
3 Réponses
+ 7
Make it a string,reverse the string,make it to integer
26th May 2021, 6:16 AM
Oma Falk
Oma Falk - avatar
0
You can also combine %10 and //10 (integer division) if you want to avoid string conversion. But it is a bit more complicated.
26th May 2021, 6:44 AM
Thoq!
Thoq! - avatar
0
As per Frogged suggestion num = 42 print(int(str(num)[::-1])*2)
26th May 2021, 8:52 AM
Rik Wittkopp
Rik Wittkopp - avatar