xxxxxxxxxx
def unique_list(l):
ulist = []
[ulist.append(x) for x in l if x not in ulist]
return ulist
a="calvin klein design dress calvin klein"
a=' '.join(unique_list(a.split()))
xxxxxxxxxx
>>> foo = 'mppmt'
>>> ''.join(sorted(set(foo), key=foo.index))
'mpt'
xxxxxxxxxx
# removing duplicated from the list using naive methods
# initializing list
sam_list = [11, 13, 15, 16, 13, 15, 16, 11]
print ("The list is: " + str(sam_list))
# remove duplicated from list
result = []
for i in sam_list:
if i not in result:
result.append(i)
# printing list after removal
print ("The list after removing duplicates : " + str(result))
xxxxxxxxxx
word = input().split()
for i in word:
if word.count(i) > 1:
word.remove(i)
xxxxxxxxxx
if mylist:
mylist.sort()
last = mylist[-1]
for i in range(len(mylist)-2, -1, -1):
if last == mylist[i]:
del mylist[i]
else:
last = mylist[i]
# Quicker if all elements are hashables:
mylist = list(set(mylist))
xxxxxxxxxx
tempA = []
uniqueDict = dict()
for key, val in thisdict.items():
if val not in tempA:
tempA.append(val)
uniqueDict[key] = val