


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Introduction
Creating Lists In Python, lists are created by enclosing elements in square brackets []. Example:
fruits = ["apple", "banana", "cherry"] Accessing Elements
first_fruit = fruits[0] Accesses the first element ("apple") Common List Operations Adding Elements fruits.remove("banana") Removes the first "banana" found. fruits.sort() Sorts the list in alphabetical order.
List Slicing - You can extract a portion (slice) of a list using slicing notation. Example: ```python subset = fruits[1:3] Extracts elements at index 1 and 2 ("banana" and "cherry") Nested Lists matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] Summary: