Python Practice › List Programs › Program 76

Remove duplicate strings

EasyList Programs · 76 of 100

Write a Python program to remove duplicate strings from a list.

Advertisement
Input
["python", "is", "a", "best", "language", "python", "best"]
Output
['python', 'is', 'a', 'best', 'language']

Approach

  1. dict.fromkeys.

Solution

Python
words = ["python", "is", "a", "best", "language", "python", "best"]print(list(dict.fromkeys(words)))
Output
['python', 'is', 'a', 'best', 'language']

Learn the concept

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

More list programs

← All 100 List Programs

Leave a Comment