Practice Looping Through a List - 8.6 | Lists in Python | Python Programming Language
Students

Academic Programs

AI-powered learning for grades 8-12, aligned with major curricula

Professional

Professional Courses

Industry-relevant training in Business, Technology, and Design

Games

Interactive Games

Fun games to boost memory, math, typing, and English skills

Looping Through a List

8.6 - Looping Through a List

Enroll to start learning

You’ve not yet enrolled in this course. Please enroll for free to listen to audio lessons, classroom podcasts and take practice test.

Learning

Practice Questions

Test your understanding with targeted questions

Question 1 Easy

Write a for loop to print each number in the list [1, 2, 3].

💡 Hint: Remember, you need to iterate through the list.

Question 2 Easy

What does len(fruits) return if fruits is ['apple', 'banana', 'cherry']?

💡 Hint: Think about how many fruits are in the list.

4 more questions available

Interactive Quizzes

Quick quizzes to reinforce your learning

Question 1

What does a for loop do?

Repeats a block of code until a condition is false
Repeats a block of code for each item in an iterable
Creates an infinite loop

💡 Hint: Think about when you want to perform an action for each item.

Question 2

True or False: A while loop must have a condition that evaluates to false to stop executing.

True
False

💡 Hint: Imagine it like a door that stays open while the light is on.

Get performance evaluation

Challenge Problems

Push your limits with advanced challenges

Challenge 1 Hard

Create a program that uses a while loop to ask for input until the user types 'quit', printing each input back.

💡 Hint: Think about how to prompt for input continually.

Challenge 2 Hard

Write a function that accepts a list of integers and returns a new list containing only the even numbers, using a for loop.

💡 Hint: Remember to check each number's remainder when divided by 2.

Get performance evaluation

Reference links

Supplementary resources to enhance your learning experience.