Python Practice › Set Programs › Program 46

Set of favourite movies

EasySet Programs · 46 of 48

Write a Python program to create a set of favourite movies and add one more.

Advertisement
Output
['Dangal', 'Inception', 'Interstellar', 'Lagaan']

Approach

  1. add() then print sorted.

Solution

Python
movies = {"Inception", "Dangal", "Interstellar"}movies.add("Lagaan")print(sorted(movies))
Output
['Dangal', 'Inception', 'Interstellar', 'Lagaan']

Learn the concept

New to this topic? Read the lesson, then come back.

More set programs

← All 48 Set Programs

Leave a Comment