Lesson 11
Looping Through Lists
Process every item in a list
1What Are Lists?✨
Lists are used to store multiple items in a single variable. You can think of a list as a collection of things, like a shopping list or a list of your favorite games.
2Creating a List🎯
You can create a list by placing items inside square brackets [] and separating them with commas. Here's an example:
games = ["Minecraft", "Among Us", "Fortnite"]This creates a list called games with three video game titles.
3Looping Through a List💡
To process each item in a list, you can use a for loop. This allows you to perform an action for every item in the list. Here's how it works:
for game in games:
print(game)This will print each game in the list one by one.
4Using the Index🚀
You can also access items in a list using their index (position). Remember, Python uses zero-based indexing. Here's an example:for i in range(len(games)):
print(f"Game {i + 1}: {games[i]}")This prints each game with its number in the list.
5Modifying Items in a List🔍
You can change items in a list using their index. For example, if you want to replace "Fortnite" with "Roblox":
games[2] = "Roblox"6Now, if you print the list, it will show the updated games:⭐
print(games)7This will display: ['Minecraft', 'Among Us', 'Roblox']🧩
8What You'll Practice🎈
- ✓ Looping through lists with for loops
- ✓ Accessing items using indices
- ✓ Modifying list items
- ✓ Creating and using your own lists
Keep practicing! Looping through lists is a powerful way to work with data in Python.
🎯 Practice Challenges
Master Looping Through Lists by completing all 3 difficulty levels
Looping Through Lists - Easy Challenge
Start with the basics. Perfect for beginners!
Looping Through Lists - Medium Challenge
Get more challenging. Build your confidence!
Looping Through Lists - Hard Challenge
Master this concept. Prove your skills!
🏆 Study a lesson for 2+ minutes to earn +10 TalentJR Points a day. Badges, certificates & prizes →
Ready to Master Looping Through Lists? 🚀
Complete the challenges, take the quiz and keep your learning streak going!
Keep learning
- ← Previous lessonLesson 10: Introduction to ListsStore and loop through collections
- Next lesson →Lesson 12: Building a Multiplication ToolCombine loops and conditions in a real tool
- Grade 7 coursePython Functions & DataPython coding course for kids.
- Student ToolsFree calculators for studentsPercentage, fraction, ratio and marks calculators with steps.
- CBSEClass 6 CBSE & NCERT study materialMaths, Science and Computer chapters with solutions.
- Future SkillsExplore future skillsAI, robotics and new-age skills explained for students.