Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

List Comprehensions | Python Fundamentals lesson | BraveProgrammer
  1. Courses
  2. /
  3. Python Fundamentals

Lesson 14 of 55

·Python

List Comprehensions

20 minutes

Course progress25%

What you'll learn

Keep these ideas in mind as you work through the lesson.

3 points
  • Compact syntax for generating lists.
  • Structure: `[expr for var in iterable if filter]`.
  • Can replace many `for` loops and `append()` calls.

List Comprehensions

List comprehensions provide a concise way to create lists from existing iterables, optionally filtering or applying an expression.

# Squares of numbers 0‑9
squares = [x * x for x in range(10)]
print(squares)

# Filtering even numbers from 0‑19
evens = [x for x in range(20) if x % 2 == 0]
print(evens)

The general syntax is [expression for item in iterable if condition].

Make it stickPractice what you've learned1 quiz · 5 practical tests · Optional activities from Python FundamentalsBrowse activities
Previous lessonData Structures – ListsContinue to lesson 15Data Structures – TuplesBack to Python Fundamentals curriculum