Solution:
You can easily remove the duplicates from a string in a python program. It can be done as an orderly format and disorderly format too. I am putting two different ways in a single program. I think it will help you to understand better.
from collections import OrderedDict
def removeDuplicatesDisorderly(mystr):
return "".join(set(mystr))
def removeDuplicatesOrderly(mystr):
return "".join(OrderedDict.fromkeys(mystr))
if __name__ == "__main__":
mystr = "australia"
print "Without Order = ",removeDuplicatesDisorderly(mystr)
print "With Order = ",removeDuplicatesOrderly(mystr)
And the output you will get:
Without Order = ailsrut
With Order = austrli
This might help you to understand the program easily. Keep coding.