Working with text and strings
A good starting point with Python is to get to grips with basic text handling and strings. A string is a block of characters stored together as a value. As you will see, they can be viewed as a simple list of characters.
We will create a script to obtain the user's input, use string manipulation to switch around the letters, and print out a coded version of the message. We then extend this example by demonstrating how encoded messages can be passed between parties without revealing the encoding methods, while also showing how we can reuse sections of code within other Python modules.
Getting ready
You can use most text editors to write Python code. They can be used directly on the Raspberry Pi or remotely through VNC or SSH.
The following are a few text editors that are available with the Raspberry Pi:
nano: This text editor is available from the terminal and includes syntax highlighting and line numbers (with the
-c
option). Refer to the following screenshot: