← All Exercises

List Comprehension Patterns

basicpython~10min

Background

List comprehensions are a Pythonic way to create lists with concise, readable syntax.

Problem

Given a list of numbers, use list comprehension to filter and transform values in a single expression.

Input

A list of numbers

Output

A filtered and transformed list

Sample tests

Sample 1

Input: [1,2,3,4,5,6]
Expected: [4, 16, 36]

Your solution

Learning objective

Learn Pythonic list processing and comprehension syntax