
Lists in Python are like super-powered containers that can hold multiple items at once! Think of them as a smart shopping list that can store anything - numbers, text, or even other lists.
In everyday life, lists are like your playlist of favorite songs, your collection of toys, or a list of ingredients for your favorite snack!
Ordered:
The order of items is preserved, just like beads on a string.
Mutable:
Unlike strings, lists can be changed after creation! You can add, remove, or modify items.
Heterogeneous:
Lists can contain different types of items - numbers, strings, and even other lists!
# A list of numbersnumbers = [369, 630, 999]# A mixed data type listmixed_list = [369, "Tesla", 3.14]What's happening here?
In these examples, we've created different types of lists. The first contains only numbers, while the second contains a number, a string, and a decimal number - all in one list!
Remember: Both lists and strings can be indexed and sliced in the same way!my_list[0] andmy_string[0] both give you the first element.