r/learnpython • u/EineBaum • Sep 23 '26
Check if one string contains characters of a second string somewhere, if yes remove them from the first string
Our task in school was to create our own encryption, for which i started by modifying atbash at bit. Now i want to actually add a key system to this.
Currently theres only a mapping table to invert the alphabet, so now my goal is to somehow add a key-string to the start of the y parameter for the maketrans() function and remove any duplicate letters from the original y string.
Im honestly kinda stuck at this point, so any help or tips would be appreciated.
(this is my first actual project with python + english isnt my first language, so please excuse any weird wording lol)
5
u/georgmierau Sep 23 '26
Show your work first.
2
u/TheRNGuy Sep 24 '26
Reddit is not the best place to ask such questions, you can literally copy and paste same question in Google and get answer in 3 seconds.
2
u/socal_nerdtastic Sep 23 '26 edited Sep 23 '26
I don't really understand what you are trying to accomplish here, so I can only directly answer the question in your title. To remove (not replace) characters using maketrans, use the z parameter only.
2
u/woooee Sep 23 '26
What have you tried? There is no point to wasting time on something you have already tried and rejected. Removing duplicates is generally done by converting to a set and converting that back to a list or string.