Python Practice › List Programs › Program 91

Tuples to sublists

EasyList Programs · 91 of 100

Write a Python program to convert the tuples in a list into lists.

Advertisement
Input
[(3, 5), (6, 8), (8, 11), (12, 14), (17, 23)]
Output
[[3, 5], [6, 8], [8, 11], [12, 14], [17, 23]]

Approach

  1. list(t) for each tuple.

Solution

Python
data = [(3, 5), (6, 8), (8, 11), (12, 14), (17, 23)]print([list(t) for t in data])
Output
[[3, 5], [6, 8], [8, 11], [12, 14], [17, 23]]
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More list programs

← All 100 List Programs