Practice · Python

Practice List Comprehensions

Build lists with comprehensions, including a filtering condition, as a concise alternative to accumulator loops.

List Comprehensionswarming python…

Space Data Processor

Write a function process_space_data(n, words) that receives an integer n (the number of mission days) and a list of strings words (names of celestial objects). Return a tuple of three lists:

  1. squares – the squares of every integer from 1 to n inclusive.
  2. evens – all even numbers from 1 to n inclusive.
  3. transformed – each word converted to uppercase and prefixed with the space‑emoji "🌌 ".

Example:

process_space_data(3, ["moon", "star"])
# returns ([1, 4, 9], [2], ["🌌 MOON", "🌌 STAR"])
Press Run to see output, or Check to grade against the tests.

Want a whole course built around list comprehensions?

Start my path — free

Adaptive practice, streaks, projects with real code review. Free tier gates AI help, never content.