Search the courses, subjects, tracks, games and features, or jump straight to a page.
2 cards from this section. Quick, good the night before a test.
Write a for loop to print each number in the list [1, 2, 3].
Remember, you need to iterate through the list.
What does len(fruits) return if fruits is ['apple', 'banana', 'cherry']?
Think about how many fruits are in the list.
What does a for loop do?
Think about when you want to perform an action for each item.
True or False: A while loop must have a condition that evaluates to false to stop executing.
Imagine it like a door that stays open while the light is on.
Create a program that uses a while loop to ask for input until the user types 'quit', printing each input back.
Think about how to prompt for input continually.
Write a function that accepts a list of integers and returns a new list containing only the even numbers, using a for loop.
Remember to check each number's remainder when divided by 2.
4 more questions in this section. Enroll free to practise them all.
Enroll free