MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / remove_duplicates

Function remove_duplicates

ciphers/simple_keyword_cypher.py:1–17  ·  view source on GitHub ↗

Removes duplicate alphabetic characters in a keyword (letter is ignored after its first appearance). :param key: Keyword to use :return: String with duplicates removed >>> remove_duplicates('Hello World!!') 'Helo Wrd'

(key: str)

Source from the content-addressed store, hash-verified

1def remove_duplicates(key: str) -> str:
2 """
3 Removes duplicate alphabetic characters in a keyword (letter is ignored after its
4 first appearance).
5
6 :param key: Keyword to use
7 :return: String with duplicates removed
8
9 >>> remove_duplicates('Hello World!!')
10 'Helo Wrd'
11 """
12
13 key_no_dups = ""
14 for ch in key:
15 if ch == " " or (ch not in key_no_dups and ch.isalpha()):
16 key_no_dups += ch
17 return key_no_dups
18
19
20def create_cipher_map(key: str) -> dict[str, str]:

Callers 1

create_cipher_mapFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected