Substitution Ciphers

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

  1. Start a new python program
  2. Start by setting up a blank variable called plainText. We'll add to this one character at a time
  3. And set a variable called theCode to 1 so that the loop knows what the variable is
  4. Then set up a while loop as shown. This will keep running until the user enters 0
  5. Use an input statement to get the user to enter a single ASCII code (like 107)
  6. Use your code from step 2 to convert theCode into theChar
  7. Now add it to the plainText variable as shown
  8. And print plainText at the end outside the loop

Code image

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