Introduction: Python - Remove Integer Duplicates From List Using Set()

About: Occupation: tech support

# Create list of integers; in Python, it is similar to arrays
ListOfIntegers = [1,2,3,4,2,3,4]

# print ListOfIntegers
print ("The original list of integers is: ")
print (ListOfIntegers)

# Run ListOfIntegers through set() to remove duplicates
# Place into variable
ListWithoutDuplicates = list(set(ListOfIntegers))

# Print out list with duplicates stripped out
print("The list without duplicates is: ")
print (ListWithoutDuplicates)

Supplies

- Computer with Windows, Linux or OS X
- Python language installed
- IDLE - Python's Integrated Development and Learning Environment