Advertisement
mateon1

leetize.py

May 26th, 2013
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. DICTFILE="LeetDict.txt" # http://pastebin.com/fnyFXLyN
  2.  
  3. with open(DICTFILE,"r") as f:
  4.     temp=f.read().split("\n")
  5.  
  6. LeetDict={}
  7.  
  8. for i in temp:
  9.     if i:
  10.         LeetDict[i.split(":")[0]]=i.split(":")[1]
  11.  
  12. def leetize(string,leetz=("etiolsazbg","3710154289"),shorts=LeetDict):
  13.     res=""
  14.     for i in shorts:
  15.         string=string.replace(i,shorts[i])
  16.     for i in string:
  17.         if i.lower() in leetz[0]:
  18.             res+=leetz[1][leetz[0].index(i.lower())]
  19.         else:res+=i
  20.     return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement