Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. from string import capwords
  2.  
  3. _CYPHER = {
  4. "a" : "ka",
  5. "b" : "tu",
  6. "c" : "mi",
  7. "d" : "te",
  8. "e" : "ku",
  9. "f" : "lu",
  10. "g" : "ji",
  11. "h" : "ri",
  12. "i" : "ki",
  13. "j" : "zu",
  14. "k" : "me",
  15. "l" : "ta",
  16. "m" : "rin",
  17. "n" : "to",
  18. "o" : "mo",
  19. "p" : "no",
  20. "q" : "ke",
  21. "r" : "shi",
  22. "s" : "ari",
  23. "t" : "chi",
  24. "u" : "do",
  25. "v" : "ru",
  26. "w" : "mei",
  27. "x" : "na",
  28. "y" : "fu",
  29. "z" : "zi"
  30. }
  31.  
  32. def replacement(cypher, string):
  33. """Given a cypher, performs a substitution on string and returns the result."""
  34. string_to_return = ""
  35. for char in string.lower():
  36. try:
  37. string_to_return = string_to_return + cypher[char]
  38. except:
  39. string_to_return = string_to_return + " "
  40.  
  41. return string_to_return
  42.  
  43. while True:
  44. r = raw_input("String?")
  45. print capwords(replacement(_CYPHER, r))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement