Lists: A Basket of Stuff ๐งบ
A variable holds one thing. But what if you have a whole squad?
A list is one variable that holds many things. You make one with
square brackets [ ] and commas between the items:
snacks = ["popcorn", "grapes", "cheese"]
print(snacks) # โ ['popcorn', 'grapes', 'cheese']
Lists can hold numbers too:
lucky_numbers = [7, 13, 21]
Notice that printing a whole list shows the square brackets and quotes. That's Python saying "here's the whole basket!"
Your mission
- Make a list called
squadwith at least 4 names in it - Make a list called
snackswith at least 3 snacks in it - Print both lists
Your code
Press โถ Run to see what your code does!