Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

‎get_dup_chars.py‎

Lines changed: 16 additions & 0 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /