Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- class cypher():
- def __init__(self, text):
- self.text = text
- def multiple_replace(text):
- dict = {
- "a": "z",
- "b": "y",
- "c": "x",
- "f": "u",
- "d": "w",
- "e": "v",
- }
- # Create a regular expression from the dictionary keys
- regex = re.compile("(%s)" % "|".join(map(re.escape, dict.keys())))
- # For each match, look-up corresponding value in dictionary
- return regex.sub(lambda mo: dict[mo.string[mo.start():mo.end()]], text)
- test = input(str('What do you want cyphered. '))
- fixed = cypher.multiple_replace(test)
- print()
- print(fixed)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement