```if-not:rust
Your task is to write a function `toLeetSpeak` that converts a regular english sentence to Leetspeak.
```
```if:rust
Your task is to write a function `to_leet_speak` that converts a regular english sentence to Leetspeak.
```

More about LeetSpeak You can read at wiki -> https://en.wikipedia.org/wiki/Leet

Consider only uppercase letters (no lowercase letters, no numbers) and spaces.

For example:

```if-not:rust
~~~
toLeetSpeak("LEET") returns "1337"
~~~
```
```if:rust
~~~
to_leet_speak("LEET") returns "1337"
~~~
```

In this kata we use a simple LeetSpeak dialect. Use this alphabet:

```
{
  A : '@',
  B : '8',
  C : '(',
  D : 'D',
  E : '3',
  F : 'F',
  G : '6',
  H : '#',
  I : '!',
  J : 'J',
  K : 'K',
  L : '1',
  M : 'M',
  N : 'N',
  O : '0',
  P : 'P',
  Q : 'Q',
  R : 'R',
  S : '$',
  T : '7',
  U : 'U',
  V : 'V',
  W : 'W',
  X : 'X',
  Y : 'Y',
  Z : '2'
}
```

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def to_leet_speak(str):
	

Solutions:
def to_leet_speak(str):
	return str.translate(str.maketrans('ABCEGHILOSTZ', '@8(36#!10$72'))


def to_leet_speak(str):
	leet = {'A': '@', 'B': '8', 'C': '(', 'D': 'D', 'E': '3', 'F': 'F', 'G': '6', 'H': '#', 'I': '!', 'J': 'J', 'K': 'K', 'L': '1', 'M': 'M', 'N': 'N', 'O': '0', 'P': 'P', 'Q': 'Q', 'R': 'R', 'S': '$', 'T': '7', 'U': 'U', 'V': 'V', 'W': 'W', 'X': 'X', 'Y': 'Y', 'Z': '2'}
	for key in leet:
		str = str.replace(key, leet[key])
	return str


table = str.maketrans('ABCDEFGHIJKLMNOPQRSTUVWXYZ', '@8(D3F6#!JK1MN0PQR$7UVWXY2')

def to_leet_speak(text):
	return text.translate(table)


def to_leet_speak(s):
	r = {'.': '.', '!': '!', '?': '?', ',': ',', ' ': ' ', 'A': '@', 'B': '8', 'C': '(', 'D': 'D', 'E': '3', 'F': 'F', 'G': '6', 'H': '#', 'I': '!', 'J': 'J', 'K': 'K', 'L': '1', 'M': 'M', 'N': 'N', 'O': '0', 'P': 'P', 'Q': 'Q', 'R': 'R', 'S': '$', 'T': '7', 'U': 'U', 'V': 'V', 'W': 'W', 'X': 'X', 'Y': 'Y', 'Z': '2'}
	return ''.join((r[c] for c in s))


from string import ascii_uppercase
tr = str.maketrans(ascii_uppercase, '@8(D3F6#!JK1MN0PQR$7UVWXY2')

def to_leet_speak(s):
	return s.translate(tr)


LEET = {'A': '@', 'B': '8', 'C': '(', 'E': '3', 'G': '6', 'H': '#', 'I': '!', 'L': '1', 'O': '0', 'S': '$', 'T': '7', 'Z': '2'}

def to_leet_speak(s):
	return ''.join((LEET.get(a, a) for a in s))


def to_leet_speak(str):
	leet = {'A': '@', 'B': '8', 'C': '(', 'E': '3', 'G': '6', 'H': '#', 'I': '!', 'L': '1', 'O': '0', 'S': '$', 'T': '7', 'Z': '2'}
	return ''.join([leet[letter] if letter in leet.keys() else letter for letter in str])


table = str.maketrans('ABCEGHILOSTZ', '@8(36#!10$72')

def to_leet_speak(stg):
	return stg.translate(table)


def to_leet_speak(str):
	return str.translate(str.maketrans('ABCDEFGHIJKLMNOPQRSTUVWXYZ', '@8(D3F6#!JK1MN0PQR$7UVWXY2'))


def to_leet_speak(str):
	return str.replace('A', '@').replace('B', '8').replace('C', '(').replace('E', '3').replace('G', '6').replace('H', '#').replace('I', '!').replace('L', '1').replace('O', '0').replace('S', '$').replace('T', '7').replace('Z', '2')


LEET_ALPHABET = '@8(D3F6#!JK1MN0PQR$7UVWXY2'

def to_leet_speak(str):
	return ''.join((LEET_ALPHABET[ord(c) - ord('A')] if c.isalpha() else c for c in str))


alphabet = dict(list(zip(__import__('string').ascii_uppercase, '@8(D3F6#!JK1MN0PQR$7UVWXY2')))

def to_leet_speak(str_):
	return ''.join((alphabet.get(x, x) for x in str_))


def to_leet_speak(str):
	(newStr, replace) = ('', '@8(D3F6#!JK1MN0PQR$7UVWXY2')
	for each in str:
		if ord(each) - ord('A') >= 0 <= 26:
			newStr += replace[ord(each) - ord('A')]
		else:
			newStr += each
	return newStr


def to_leet_speak(str):
	leet = {'A': '@', 'B': '8', 'C': '(', 'E': '3', 'G': '6', 'H': '#', 'I': '!', 'L': '1', 'O': '0', 'S': '$', 'T': '7', 'Z': '2'}
	newstr = ''
	for c in str:
		if c in leet:
			newstr += leet[c]
		else:
			newstr += c
	return newstr


to_leet_speak = lambda str: (lambda base: ''.join([base[l] if l in base else l for l in str]))({'A': '@', 'B': '8', 'C': '(', 'E': '3', 'G': '6', 'H': '#', 'I': '!', 'L': '1', 'O': '0', 'S': '$', 'T': '7', 'Z': '2'})


to_leet_speak = lambda s: s.translate(str.maketrans('ABCDEFGHIJKLMNOPQRSTUVWXYZ', '@8(D3F6#!JK1MN0PQR$7UVWXY2'))


LEETDICT = {'A': '@', 'B': '8', 'C': '(', 'D': 'D', 'E': '3', 'F': 'F', 'G': '6', 'H': '#', 'I': '!', 'J': 'J', 'K': 'K', 'L': '1', 'M': 'M', 'N': 'N', 'O': '0', 'P': 'P', 'Q': 'Q', 'R': 'R', 'S': '$', 'T': '7', 'U': 'U', 'V': 'V', 'W': 'W', 'X': 'X', 'Y': 'Y', 'Z': '2', ' ': ' '}
to_leet_speak = lambda str: ''.join([LEETDICT[i] for i in list(str)])


import string

def to_leet_speak(s):
	return s.translate(str.maketrans({'A': '@', 'B': '8', 'C': '(', 'D': 'D', 'E': '3', 'F': 'F', 'G': '6', 'H': '#', 'I': '!', 'J': 'J', 'K': 'K', 'L': '1', 'M': 'M', 'N': 'N', 'O': '0', 'P': 'P', 'Q': 'Q', 'R': 'R', 'S': '$', 'T': '7', 'U': 'U', 'V': 'V', 'W': 'W', 'X': 'X', 'Y': 'Y', 'Z': '2'}))


def to_leet_speak(str):
	st = ''
	d = {'A': '@', 'B': '8', 'C': '(', 'D': 'D', 'E': '3', 'F': 'F', 'G': '6', 'H': '#', 'I': '!', 'J': 'J', 'K': 'K', 'L': '1', 'M': 'M', 'N': 'N', 'O': '0', 'P': 'P', 'Q': 'Q', 'R': 'R', 'S': '$', 'T': '7', 'U': 'U', 'V': 'V', 'W': 'W', 'X': 'X', 'Y': 'Y', 'Z': '2', ' ': ' '}
	for x in range(len(str)):
		st = st + d.get(str[x])
	return st


def to_leet_speak(str):
	x = {'A': '@', 'B': '8', 'C': '(', 'D': 'D', 'E': '3', 'F': 'F', 'G': '6', 'H': '#', 'I': '!', 'J': 'J', 'K': 'K', 'L': '1', 'M': 'M', 'N': 'N', 'O': '0', 'P': 'P', 'Q': 'Q', 'R': 'R', 'S': '$', 'T': '7', 'U': 'U', 'V': 'V', 'W': 'W', 'X': 'X', 'Y': 'Y', 'Z': '2'}
	z = ''
	for i in str:
		if i in x:
			z += x[i]
		else:
			z += i
	return z


def to_leet_speak(str):
	leet_dict = {'A': '@', 'B': '8', 'C': '(', 'D': 'D', 'E': '3', 'F': 'F', 'G': '6', 'H': '#', 'I': '!', 'J': 'J', 'K': 'K', 'L': '1', 'M': 'M', 'N': 'N', 'O': '0', 'P': 'P', 'Q': 'Q', 'R': 'R', 'S': '$', 'T': '7', 'U': 'U', 'V': 'V', 'W': 'W', 'X': 'X', 'Y': 'Y', 'Z': '2'}
	return ''.join([leet_dict.get(char.upper(), ' ') for char in str])


def to_leet_speak(str):
	str = str.upper()
	new = str.maketrans('ABCDEFGHIJKLMNOPQRSTUVWXYZ', '@8(D3F6#!JK1MN0PQR$7UVWXY2')
	return str.translate(new)


d = {'A': '@', 'B': '8', 'C': '(', 'D': 'D', 'E': '3', 'F': 'F', 'G': '6', 'H': '#', 'I': '!', 'J': 'J', 'K': 'K', 'L': '1', 'M': 'M', 'N': 'N', 'O': '0', 'P': 'P', 'Q': 'Q', 'R': 'R', 'S': '$', 'T': '7', 'U': 'U', 'V': 'V', 'W': 'W', 'X': 'X', 'Y': 'Y', 'Z': '2'}

def to_leet_speak(str):
	a = []
	for i in range(len(str)):
		if str[i] in list(d.keys()):
			a.append(d[str[i]])
		else:
			a.append(str[i])
	p = ''.join(a)
	return p


LEET_DICT = {'A': '@', 'B': '8', 'C': '(', 'D': 'D', 'E': '3', 'F': 'F', 'G': '6', 'H': '#', 'I': '!', 'J': 'J', 'K': 'K', 'L': '1', 'M': 'M', 'N': 'N', 'O': '0', 'P': 'P', 'Q': 'Q', 'R': 'R', 'S': '$', 'T': '7', 'U': 'U', 'V': 'V', 'W': 'W', 'X': 'X', 'Y': 'Y', 'Z': '2'}

def to_leet_speak(english):
	leet_translation = ''
	for letter in english.upper():
		if letter in LEET_DICT:
			leet_translation += LEET_DICT.get(letter)
		else:
			leet_translation += letter
	return leet_translation


elite_dict = {'A': '@', 'B': '8', 'C': '(', 'D': 'D', 'E': '3', 'F': 'F', 'G': '6', 'H': '#', 'I': '!', 'J': 'J', 'K': 'K', 'L': '1', 'M': 'M', 'N': 'N', 'O': '0', 'P': 'P', 'Q': 'Q', 'R': 'R', 'S': '$', 'T': '7', 'U': 'U', 'V': 'V', 'W': 'W', 'X': 'X', 'Y': 'Y', 'Z': '2'}

def to_leet_speak(string):
	res = ''
	for i in range(len(string)):
		if string[i].upper() in elite_dict:
			res += elite_dict[string[i].upper()]
		else:
			res += ' '
	return res


def to_leet_speak(input_str):
	LEET_DICT = {'A': '@', 'B': '8', 'C': '(', 'D': 'D', 'E': '3', 'F': 'F', 'G': '6', 'H': '#', 'I': '!', 'J': 'J', 'K': 'K', 'L': '1', 'M': 'M', 'N': 'N', 'O': '0', 'P': 'P', 'Q': 'Q', 'R': 'R', 'S': '$', 'T': '7', 'U': 'U', 'V': 'V', 'W': 'W', 'X': 'X', 'Y': 'Y', 'Z': '2'}
	output_str = ''
	for char in input_str.upper():
		if char in LEET_DICT.keys():
			output_str += LEET_DICT[char]
		else:
			output_str += char
	return output_str


import string
str1 = string.ascii_uppercase
str2 = '@8(D3F6#!JK1MN0PQR$7UVWXY2'

def to_leet_speak(s):
	table = str.maketrans(str1, str2)
	return s.translate(table)


def to_leet_speak(str):
	dict = {'A': '@', 'B': '8', 'C': '(', 'D': 'D', 'E': '3', 'F': 'F', 'G': '6', 'H': '#', 'I': '!', 'J': 'J', 'K': 'K', 'L': '1', 'M': 'M', 'N': 'N', 'O': '0', 'P': 'P', 'Q': 'Q', 'R': 'R', 'S': '$', 'T': '7', 'U': 'U', 'V': 'V', 'W': 'W', 'X': 'X', 'Y': 'Y', 'Z': '2', ' ': ' '}
	l = []
	string = list(str)
	for key in string:
		l.append(dict[key])
	return ''.join(l)


def to_leet_speak(str):
	return str.translate(str.maketrans('IHACOLZEGTBS', '!#@(0123678$'))


D = {65: '@', 66: '8', 67: '(', 68: 'D', 69: '3', 70: 'F', 71: '6', 72: '#', 73: '!', 74: 'J', 75: 'K', 76: '1', 77: 'M', 78: 'N', 79: '0', 80: 'P', 81: 'Q', 82: 'R', 83: '$', 84: '7', 85: 'U', 86: 'V', 87: 'W', 88: 'X', 89: 'Y', 90: '2'}

def to_leet_speak(str):
	return str.translate(D)


from string import ascii_uppercase

def to_leet_speak(str):
	trans = str.maketrans(ascii_uppercase, '@8(D3F6#!JK1MN0PQR$7UVWXY2')
	return str.translate(trans)


leetDict = {'A': '@', 'B': '8', 'C': '(', 'D': 'D', 'E': '3', 'F': 'F', 'G': '6', 'H': '#', 'I': '!', 'J': 'J', 'K': 'K', 'L': '1', 'M': 'M', 'N': 'N', 'O': '0', 'P': 'P', 'Q': 'Q', 'R': 'R', 'S': '$', 'T': '7', 'U': 'U', 'V': 'V', 'W': 'W', 'X': 'X', 'Y': 'Y', 'Z': '2', ' ': ' '}

def to_leet_speak(str):
	natList = list(str)
	leetList = []
	for i in natList:
		leetList.append(leetDict[i])
	return ''.join(leetList)


def to_leet_speak(str):
	getchar = lambda c: chars[c] if c in chars else c
	chars = {'A': '@', 'B': '8', 'C': '(', 'D': 'D', 'E': '3', 'F': 'F', 'G': '6', 'H': '#', 'I': '!', 'J': 'J', 'K': 'K', 'L': '1', 'M': 'M', 'N': 'N', 'O': '0', 'P': 'P', 'Q': 'Q', 'R': 'R', 'S': '$', 'T': '7', 'U': 'U', 'V': 'V', 'W': 'W', 'X': 'X', 'Y': 'Y', 'Z': '2'}
	return ''.join((getchar(c) for c in str))


import unittest
MAPPING_TABLE = {'A': '@', 'B': '8', 'C': '(', 'D': 'D', 'E': '3', 'F': 'F', 'G': '6', 'H': '#', 'I': '!', 'J': 'J', 'K': 'K', 'L': '1', 'M': 'M', 'N': 'N', 'O': '0', 'P': 'P', 'Q': 'Q', 'R': 'R', 'S': '$', 'T': '7', 'U': 'U', 'V': 'V', 'W': 'W', 'X': 'X', 'Y': 'Y', 'Z': '2', ' ': ' '}

def to_leet_speak(str_):
	return ''.join((MAPPING_TABLE[char] for char in str_))

class TestToLeekSpeak(unittest.TestCase):

	def test_to_leek_speak(self):
		str_ = 'LEET'
		actual = to_leek_speak(str_)
		self.assertEqual(actual, '1337')

	def test_to_leek_speak_with_empty_space(self):
		str_ = 'HELLO WORLD'
		actual = to_leek_speak(str_)
		self.assertEqual(actual, '#3110 W0R1D')


def to_leet_speak(p):
	db = {'A': '@', 'B': '8', 'C': '(', 'D': 'D', 'E': '3', 'F': 'F', 'G': '6', 'H': '#', 'I': '!', 'J': 'J', 'K': 'K', 'L': '1', 'M': 'M', 'N': 'N', 'O': '0', 'P': 'P', 'Q': 'Q', 'R': 'R', 'S': '$', 'T': '7', 'U': 'U', 'V': 'V', 'W': 'W', 'X': 'X', 'Y': 'Y', 'Z': '2', ' ': ' '}
	lol = [db.get(item) for item in p]
	l = [str(i) for i in lol]
	return ''.join(l)


def to_leet_speak(string):
	trans = str.maketrans({'A': '@', 'B': '8', 'C': '(', 'E': '3', 'G': '6', 'H': '#', 'I': '!', 'L': '1', 'O': '0', 'S': '$', 'T': '7', 'Z': '2'})
	return string.translate(trans)


def to_leet_speak(str):
	LeetSpeak = {'A': '@', 'B': '8', 'C': '(', 'E': '3', 'G': '6', 'H': '#', 'I': '!', 'L': '1', 'O': '0', 'S': '$', 'T': '7', 'Z': '2'}
	return ''.join((LeetSpeak[x] if x in LeetSpeak else x for x in str))


def to_leet_speak(text):
	return text.translate(text.maketrans('ABCEGHILOSTZ', '@8(36#!10$72'))


dictRef = {'A': '@', 'B': '8', 'C': '(', 'D': 'D', 'E': '3', 'F': 'F', 'G': '6', 'H': '#', 'I': '!', 'J': 'J', 'K': 'K', 'L': '1', 'M': 'M', 'N': 'N', 'O': '0', 'P': 'P', 'Q': 'Q', 'R': 'R', 'S': '$', 'T': '7', 'U': 'U', 'V': 'V', 'W': 'W', 'X': 'X', 'Y': 'Y', 'Z': '2', ' ': ' '}
to_leet_speak = lambda s: ''.join((dictRef[letter] for letter in s))


def to_leet_speak(str):
	s = ''
	dict = {'A': '@', 'B': '8', 'C': '(', 'D': 'D', 'E': '3', 'F': 'F', 'G': '6', 'H': '#', 'I': '!', 'J': 'J', 'K': 'K', 'L': '1', 'M': 'M', 'N': 'N', 'O': '0', 'P': 'P', 'Q': 'Q', 'R': 'R', 'S': '$', 'T': '7', 'U': 'U', 'V': 'V', 'W': 'W', 'X': 'X', 'Y': 'Y', 'Z': '2'}
	for i in str:
		try:
			s += dict[i]
		except:
			s += ' '
	return s


def to_leet_speak(str):
	key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	val = '@8(D3F6#!JK1MN0PQR$7UVWXY2'
	transform = dict(zip(key, val))
	return ''.join((transform.get(char, char) for char in str))


def to_leet_speak(str):
	dic = {'A': '@', 'B': '8', 'C': '(', 'E': '3', 'F': 'F', 'G': '6', 'H': '#', 'I': '!', 'L': '1', 'O': '0', 'S': '$', 'T': '7', 'Z': '2'}
	return ''.join((dic.get(i, i) for i in str))


def to_leet_speak(string):
	uppercase_letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	leet_speak = '@8(D3F6#!JK1MN0PQR$7UVWXY2'
	leet = dict(list(zip(uppercase_letters, leet_speak)))
	leet_builder = str()
	for letter in string:
		leet_letter = leet.get(letter)
		leet_builder += leet_letter if leet_letter else letter
	return leet_builder


from string import ascii_uppercase
L = str.maketrans(ascii_uppercase, '@8(D3F6#!JK1MN0PQR$7UVWXY2')
to_leet_speak = lambda s: s.translate(L)


from string import ascii_uppercase
ALPHABET = str.maketrans(ascii_uppercase, '@8(D3F6#!JK1MN0PQR$7UVWXY2')

def to_leet_speak(text):
	return text.translate(ALPHABET)