fork download
  1. def leet_from_str(s: str) -> str:
  2. """Converts a word or setnence to leet.
  3. :param s: An average string.
  4. :return: The contents of the string, converted to leet.
  5. """
  6.  
  7. leet_alphabet = [
  8. "4",
  9. "8",
  10. "(",
  11. "C-",
  12. "3",
  13. "|",
  14. "C-",
  15. "#",
  16. "1",
  17. "]",
  18. "|<",
  19. "|_",
  20. "[V]",
  21. "/V",
  22. "0",
  23. "|7",
  24. "9",
  25. "|2",
  26. "5",
  27. "7",
  28. "|_|",
  29. "\\/",
  30. "\\N",
  31. "><",
  32. "'/",
  33. "2"]
  34.  
  35.  
  36. s = s.lower()
  37. toret = ""
  38. ord_a = ord('a')
  39. ord_z = ord('z')
  40.  
  41. for ch in s:
  42. ord_ch = ord(ch)
  43.  
  44. if (ord_ch >= ord_a
  45. and ord_ch <= ord_z):
  46. toret += leet_alphabet[ord_ch - ord_a]
  47. else:
  48. toret += ch
  49. ...
  50. ...
  51.  
  52. return toret
  53.  
  54.  
  55. print(leet_from_str("Baltasar"))
Success #stdin #stdout 0.03s 9620KB
stdin
Standard input is empty
stdout
84|_7454|2