Welcome folks today in this blog post we will be removing duplicate or repeating characters of given string using collections in python.
All the full source code of the application is given below.
Get Started
In order to get started you need to make an app.py
file and copy paste the following code
app.py
1 2 3 4 5 6 |
from collections import OrderedDict def remove_duplicate(str1): return "".join(OrderedDict.fromkeys(str1)) print(remove_duplicate("python exercises practice solution")) print(remove_duplicate("w3resource")) |
Now if you execute the python
script by typing the below command as shown below
python app.py