Python Practice › List Programs › Program 79
Reverse every number in a list
Write a Python program to reverse the digits of every number in a list.
Input
[123, 145, 633, 654, 254]
Output
[321, 541, 336, 456, 452]
Approach
- Reverse each number’s string and convert back.
Solution
numbers = [123, 145, 633, 654, 254]print([int(str(n)[::-1]) for n in numbers])Output
[321, 541, 336, 456, 452]
Learn the concept
New to this topic? Read the lesson, then come back.