In this Python list program, we will take a user input as a list and remove the duplicate string from the list with the help of the below-given steps.
Remove the duplicate string from list:
Steps to solve the program
- Take a list containing strings as input.
- Add the strings from the given list to another list using for loop.
- If a string repeats then do not add it.
- Print the list to see the output.
#Input lists
list1 = ["python", "is", "a", "best", "language", "python", "best"]
list2 = []
for words in list1:
if words not in list2:
list2.append(words)
#Printing output
print(list2)
Output :
['python', 'is', 'a', 'best', 'language']
Related Articles
Python program to get the factorial of each item in the list.
Python program to get a list of Fibonacci numbers from 1 to 20.
Python program to reverse all the numbers in a given list.
Python program to get palindrome numbers from a given list.
Python program to get a count of vowels in the given list.
Python program to get the list of prime numbers in a given list.