Python 3 Script to Remove Duplicate or Repeating Characters of Given String Using Collections Full Project For Beginners

 

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

 

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

 

 

 

 

Leave a Reply