The simplest is to convert to a set then back to a list:
my_list = list(set(my_list))
One disadvantage with this is that it won’t preserve the order. You may also want to consider if a set would be a better data structure to use in the first place, instead of a list.
More Related Contents:
- Relative imports for the billionth time
- Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
- How to unnest (explode) a column in a pandas DataFrame, into multiple rows
- How to bind self events in Tkinter Text widget after it will binded by Text widget?
- How do I handle the window close event in Tkinter?
- How to overcome TypeError: unhashable type: ‘list’
- Not all parameters were used in the SQL statement (Python, MySQL)
- Matplotlib y axis values are not ordered [duplicate]
- How to install 2 Anacondas (Python 2 and 3) on Mac OS
- bash: pip: command not found
- What do the python file extensions, .pyc .pyd .pyo stand for?
- Why do “Not a Number” values equal True when cast as boolean in Python/Numpy?
- How to integrate Flask & Scrapy?
- How to read class attributes in the same order as declared?
- Integer division by negative number [duplicate]
- How to make Django slugify work properly with Unicode strings?
- Cannot import PyQt4.QtGui
- Handling of duplicate indices in NumPy assignments
- How to Download a File after POSTing data using FastAPI?
- How to fix “no module named ‘app_one'”
- How to disable Django’s CSRF validation?
- What is the purpose of static methods? How do I know when to use one? [duplicate]
- How to include external Python code to use in other files?
- better way to drop nan rows in pandas
- Python pandas cumsum() reset after hitting max
- Building Mesa for windows 7. Mesa 9.1
- Is .ix() always better than .loc() and .iloc() since it is faster and supports integer and label access?
- Can sys.argv handle optional arguments? [duplicate]
- ntp client in python
- add column to SQLAlchemy Table