Skip to the content.

Lists

Homework and Popcorn hacks from Lists lesson

Popcorn Hacks

Popcorn Hack 1

# Create the initial list
movies = ["Ferris Bueller's Day Off", "Wolf Of Wallstreet", "Cars", "The Fast and The Furious"]

# Replace the second movie (index 1)
movies[1] = "A Minecraft Movie"

# Add another movie to the end of the list
movies.append("A Minecraft Movie")

# Display the updated list
print(movies)

Popcorn Hack 2

ages = [15, 20, 34, 16, 18, 21, 14, 19]

# Create a new list with ages 18 or older
eligible_ages = [age for age in ages if age >= 18]

print(eligible_ages)

Homework Hacks