Arrays: Super Lists! 📋
Instead of storing one thing, an array stores MANY things — all in one place, all in order. Think of it like a row of labelled lockers!
One Variable That Holds Everything!
No more making 10 variables — one array does the job!
When I first built a game, I needed to store 5 player names. I made 5 separate variables. My teacher said — “There’s a much better way!” She showed me arrays. One line. All five names. I was amazed! 😄
player1 = "Ali" player2 = "Sara" player3 = "Zain" player4 = "Mia" player5 = "Leo"5 variables — messy!
players = [ "Ali", "Sara", "Zain", "Mia", "Leo" ]1 array — clean! 🎉
Every Item Has an Index Number!
Use the number to grab exactly what you need!
Each slot in an array has a number called an index. Use it like an address — tell the computer which slot to look in and it gives you what’s inside! Click any slot below!
👆 Tap any slot to see what the code looks like!
Fun Fact: In most coding languages, arrays start counting from ZERO (0) — not one! So the first item is always [0], the second is [1], and so on. A bit weird at first — but you’ll get used to it fast! 😄
Interactive Array Builder!
Add items, remove them, watch the code update live!
Add items — click ✕ to remove — watch the code change!
Add some items below 👇
You See Arrays Everywhere!
Any time you have a list — that’s an array in disguise!
Music Playlist
Your playlist is an array of songs — played in order, one after another!
Game Leaderboard
High scores stored in order — best score first, then second, then third!
Days of the Week
7 days stored as an array — index 0 is Monday, index 6 is Sunday!
Game Enemies
All enemies on screen are in an array — the game loops through each one every second!
3 Key Array Operations!
Add, remove, and count — the three things every coder does!
Add Items — append()
Use append() in Python to add a new item to the end of the array. Like adding something to the bottom of your shopping list!
fruits = ["apple","banana"]
fruits = ["apple","banana","orange"]
Remove Items — remove()
Use remove() to delete a specific item from the array. Like crossing something off your shopping list!
fruits = ["apple","banana","orange"]
fruits = ["apple","orange"]
Count Items — len()
Use len() to find out how many items are in your array. Super useful when you need to loop through everything!
friends = ["Ali","Sara","Zain"]
len(friends) → 3 friends!
4 questions · pick an answer to check!
⭐ Remember This!
Arrays are lists that hold many items in one place
Counting always starts at zero [0], not one!
Use append() to add items to the end
Use len() to count how many items you have
