9.02
Completed
Building Lists with Loops Building Lists with Loops

Learn how to build new Python lists by collecting, filtering, and transforming values with loops.

Building Lists with Loops

Sounds useful?

Jump into the interactive version.

No setup. No account. Just Python.

Interactive Python lesson

Building Lists with Loops

Lists become much more useful when your program can build them as it runs. This Block combines for loops, conditions, and append() into one practical pattern: create an empty list before the loop, append items inside the loop, and use the completed list afterward.

What you will learn:

  • Collect user input into a list with input() and range()
  • Filter a source list by appending only values that pass a condition
  • Transform numbers and strings while building a new list
  • Combine filtering and transformation in the same loop
  • Avoid common mistakes such as resetting the list or appending outside the loop

By the end, you will be able to turn existing values or user input into useful new lists, one loop at a time.

> Start now 105 cards · about 11 min

Ready to practice this in the browser?

> Play now