Project Description
Leet (or “1337”), also known as eleet or leetspeak, is a system of modified spellings used primarily on the Internet. (wiki).
We take an input string from the user and convert it to a simplified leet that only converts a few letters. You can extend it further if you like.
Example
'TAKE ME TO ANOTHER LEVEL'
→ '74K3 M3 70 4N07H3R 13V31'
Project Break Down
The first step in creating a project is to break it down into individual steps of what needs to be done.
This helps you as a programmer to keep it simple and not mix things together and create complex solutions. The most common mistake a programmer makes is to try to do too many things at the same time. Instead of just starting to program, you should try to think what is the logical flow that happens.
One solution could be as follows.
- Input from the user.
- Convert input to uppercase.
- Make the leet conversion
- Display the result.
This simple breakdown helps you have a simple flow in your program.
Step 1 Input from the user
The built-in function input() will prompt the user for an input and return it as a string.
phrase = input('Input phrase: ')
This will simply prompt the user and return the input from the user to the variable phrase.
Step 2 Convert input to uppercase
The string method upper() will return an uppercase version of the string.
phrase = phrase.upper()
If the user wrote ‘take me to another level’ then this will return ‘TAKE ME TO ANOTHER LEVEL’.
Step 3 Make the leet conversion
This is the core of the program and it is great to keep it isolated and not mixed up together with the other steps in the code.
A great way to transform a string into another string is to loop over it and generate it character by character.
The simplest way to make a character conversion is to use a dictionary for that.
lookup = {
'A': '4',
'E': '3',
'I': '1',
'L': '1',
'O': '0',
'S': '5',
'T': '7'
}
leet = ''
for char in phrase:
leet += lookup.get(char, char)
The lookup is a dictionary used to look up a character (the key) and another value (the value of the dictionary).
The loop iterates over each character in the string phrase and uses the dictionary get-method that will return the value if the key exists (the first argument) else it will use the default value (the second argument).
What it does if the character char is, say ‘L’, is to use lookup.get(‘L’, ‘L’) – in this case, it will return ‘1’ because it exists. On the other hand if lookup.get(‘K’, ‘K’) then it would return ‘K’ because ‘K’ does not exist in the dictionary lookup.
Step 4 Display output
Finally, we need to display the result to the user. This can be done by using the print built-in function.
print(leet)
Now you have solved it.
The full code
Here you get the full code.
# 1: Input from the user
phrase = input('Input phrase: ')
# 2: Convert input to upper case
phrase = phrase.upper()
# 3: Make the leet conversion
lookup = {
'A': '4',
'E': '3',
'I': '1',
'L': '1',
'O': '0',
'S': '5',
'T': '7'
}
leet = ''
for char in phrase:
leet += lookup.get(char, char)
# 4: Display output
print(leet)
Learn Python

Learn Python A BEGINNERS GUIDE TO PYTHON
- 70 pages to get you started on your journey to master Python.
- How to install your setup with Anaconda.
- Written description and introduction to all concepts.
- Jupyter Notebooks prepared for 17 projects.
Python 101: A CRASH COURSE
- How to get started with this 8 hours Python 101: A CRASH COURSE.
- Best practices for learning Python.
- How to download the material to follow along and create projects.
- A chapter for each lesson with a description, code snippets for easy reference, and links to a lesson video.
Expert Data Science Blueprint

Expert Data Science Blueprint
- Master the Data Science Workflow for actionable data insights.
- How to download the material to follow along and create projects.
- A chapter to each lesson with a Description, Learning Objective, and link to the lesson video.
Machine Learning

Machine Learning – The Simple Path to Mastery
- How to get started with Machine Learning.
- How to download the material to follow along and make the projects.
- One chapter for each lesson with a Description, Learning Objectives, and link to the lesson video.