Skip to content

Commit b4d4528

Browse files
author
Amogh Singhal
authored
Create get_dup_chars.py
1 parent 5b23dc9 commit b4d4528

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Diff for: get_dup_chars.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Print duplicate characters in a string
2+
3+
def get_dup_chars(input_str):
4+
dedupe_str = ''
5+
dup_chars = []
6+
7+
for char in input_str:
8+
if char not in dedupe_str:
9+
dedupe_str += char
10+
else:
11+
dup_chars.append(char)
12+
13+
return dup_chars
14+
15+
result = get_dup_chars("zmaxxazkgv")
16+
print(result) # ['x', 'a', 'z']

0 commit comments

Comments
 (0)