Remove duplicate number in Python

thumbnail

In this tutorial, you will create program to remove duplicate number in python. You don’t need to import anything. The program use list() and set() from a given list called mylist. The program is show as follow.

# Created by inpows
# Visit inpows.com for more python tutorials
 
mylist = [20, 22, 24, 22, 26, 20, 28, 26, 26, 30, 20]
print("Original number=", mylist)
# Original number= [20, 22, 24, 22, 26, 20, 28, 26, 26, 30, 20]

mylist = list(set(mylist))
print("After removing duplicate number=",mylist)
# After removing duplicate number= [20, 22, 24, 26, 28, 30]
Back To Top