Python Practice › Set Programs › Program 46
Set of favourite movies
Write a Python program to create a set of favourite movies and add one more.
Output
['Dangal', 'Inception', 'Interstellar', 'Lagaan']
Approach
add()then print sorted.
Solution
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.