Step 5 – Convert ASCII to text
It's much harder to convert a set of ASCII code to text.
That's mainly because entering the code causes all sorts of problems.
There's a way round this that will work. We just need to get the user to enter codes one at a time
- Start a new python program
- Start by setting up a blank variable called plainText. We'll add to this one character at a time
- And set a variable called theCode to 1 so that the loop knows what the variable is
- Then set up a while loop as shown. This will keep running until the user enters 0
- Use an input statement to get the user to enter a single ASCII code (like 107)
- Use your code from step 2 to convert theCode into theChar
- Now add it to the plainText variable as shown
- And print plainText at the end outside the loop
Save your program and run it.
Test it by figuring out a message to send and entering it character by character (don't forget: 032 is a space!).
You can make the same sorts of improvements as in Step 4 to this program as well