list_comprehension_example.py

movies = ["Star Wars", "Gandi", "Casablanca", "Shawshank Redemption",
        "Toy Story", "Gone With the Wind", "Citizen Kane",
        "It's a Wonderful Life", "The Wizard of Oz",
        "Gattaca", "Rear Window", "Ghostbusters", "To Kill a Mockingbird",
        "Good Will Hunting", "2001: A Space Odyssey",
        "Raiders of the Lost Ark", "Groundhog Day",
        "Close Encounters of the Third Kind"]

print("-----------------------------------------------------")

for title in movies:
    print(title)

#---- REGULAR WAY

print("-----------------------------------------------------")

gmovies1 = []
for title in movies:
    if title.startswith("G"):
        gmovies1.append(title)
print(gmovies1)

# ---- comprehension

print("------------------------------------------------------")

gmovies2 = [title for title in movies if title.startswith("G")]

print(gmovies2)