Python Practice › List Programs › Program 79

Reverse every number in a list

EasyList Programs · 79 of 100

Write a Python program to reverse the digits of every number in a list.

Advertisement
Input
[123, 145, 633, 654, 254]
Output
[321, 541, 336, 456, 452]

Approach

  1. Reverse each number’s string and convert back.

Solution

Python
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.

More list programs

← All 100 List Programs

Leave a Comment