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

Academics

AI-Powered learning for Grades 8–12, aligned with major Indian and international curricula.

Professionals

Professional Courses

Industry-relevant training in Business, Technology, and Design to help professionals and graduates upskill for real-world careers.

Games

Interactive Games

Fun, engaging games to boost memory, math fluency, typing speed, and English skillsβ€”perfect for learners of all ages.

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 related to the topic.

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.

Practice 4 more questions and get performance evaluation

Interactive Quizzes

Engage in quick quizzes to reinforce what you've learned and check your comprehension.

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.

Solve and get performance evaluation

Challenge Problems

Push your limits with challenges.

Question 1

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.

Question 2

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.

Challenge and get performance evaluation