Python Lists
💡
Exercise 27

Bucket List 20 XP Easy

Ctrl+Enter Run Ctrl+S Save

List comprehensions are a concise way to create lists:

# Instead of: squares = [] for i in range(1, 6): squares.append(i ** 2) # You can write: squares = [i ** 2 for i in range(1, 6)] print(squares) # [1, 4, 9, 16, 25]

You can also add conditions:

evens = [i for i in range(1, 11) if i % 2 == 0] print(evens) # [2, 4, 6, 8, 10]
📋 Instructions
Create a bucket list program: 1. Create a list of at least 5 things you want to do 2. Mark some as completed using a list of booleans 3. Print your bucket list with checkmarks Example: ``` My Bucket List ============== ✓ Learn Python ✗ Visit Japan ✓ Read 50 books ✗ Run a marathon ✗ Start a business ``` Use `'✓'` for done and `'✗'` for not done.
Use zip(bucket_list, completed) to loop through both lists together. Check the boolean to pick ✓ or ✗.
⚠️ Try solving it yourself first — you'll learn more!
# Instead of:
squares = []
for i in range(1, 6):
    squares.append(i ** 2)

# You can write:
squares = [i ** 2 for i in range(1, 6)]
print(squares)  # [1, 4, 9, 16, 25]
main.py
Hi! I'm Rex 👋
Output
Ready. Press ▶ Run or Ctrl+Enter.