+ 1

what is the logic for reverse a number in python??

21st Jun 2018, 6:28 PM
Madhurata *
Madhurata * - avatar
2 Respostas
+ 3
https://www.sololearn.com/post/10621/?ref=app print(list(reversed("123"))) might help else use a normal loop
21st Jun 2018, 6:36 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 3
Another way: n = 123 s = str(n) rev = s[::-1] n_rev = int(rev) # n_rev == 321
21st Jun 2018, 8:26 PM
Pedro Demingos
Pedro Demingos - avatar