Skip to content

Commit

Permalink
Merge pull request #423 from shxlxn-05/main
Browse files Browse the repository at this point in the history
Remove duplicate elements from a string in Python
  • Loading branch information
mergify[bot] committed Oct 28, 2021
2 parents 9c1b56a + 739c718 commit 05118d1
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions python/removeduplicatestring.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
def removeDuplicate(str, n):
i = 0

for j in range(0, n):
for k in range(0, j + 1):
if (str[j] == str[k]):
break

if (k == j):
str[i] = str[j]
i += 1

string = "".join(str[:i])
return string

str= str(input("Enter String Value:"))
n = len(str)
print(removeDuplicate(list(str), n))

0 comments on commit 05118d1

Please sign in to comment.