Courses
Log inStart Learning AI
Courses
Log inStart Learning AI
+ 1

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

pythonnumeric-operations
21st Jun 2018, 6:28 PM
Madhurata *
Madhurata * - avatar
2 Answers
+ 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

Often have questions like this?

Learn more efficiently, for free:

  • Introduction to Python

    7.1M learners

  • Introduction to Java

    4.7M learners

  • Introduction to C

    1.5M learners

  • Introduction to HTML

    7.5M learners

See all courses
Hot today
Ошибка в приложении Sololearn
1 Votes
Is anyone else experiencing this Sololearn issue?
0 Votes
NEO V2.0
1 Votes
Sololearn course
1 Votes
Best language?
0 Votes
solo learn program issue - iPhone?
1 Votes
Is it possible to write Rust code that is as compact and expressive as Python?
0 Votes
I am learning javascript intrmdt but when I play a code challenge. The app is givin me comlecated questions with less time.why?
0 Votes
Learn - multiple choice course questions display in one box making it impossible to continue
1 Votes
How do I keep myself motivated in coding
0 Votes