0

Can anyone tell me how to write a simple PYTHON program to reverse a 3 or 4 digit number???

Example :123~321

3rd Nov 2019, 1:57 PM
Sparsh Verma
Sparsh Verma - avatar
3 ответов
+ 6
- input a number as a string or convert an integer to a string (str) - reverse the string ([::-1]) - convert it to an integer (int)
3rd Nov 2019, 1:59 PM
Théophile
Théophile - avatar
+ 4
num = 123 num2 = int(str(num)[::-1]) print(num2) #321
3rd Nov 2019, 1:59 PM
Russ
Russ - avatar
3rd Nov 2019, 6:21 PM
Coding Cat
Coding Cat - avatar