This chapter will go into a detailed discussion of strings, basic operations that you can do strings, asking questions, and using the answers to create interactive programs.
A string is a group of letters, numbers, and symbols surrounded by single or double quotes. The computer does not understand or evaluate the contents of a string, it just treats it as a chunk of stuff. We saw string literals surrounded by quotes and triple quotes in Chapter 1.
Objectives
Upon completion of this chapter’s exercises, you should be able to:
- Use the string operators to concatenate and repeat strings to build new strings.
- Apply the correct type of quite marks around a string.
- Show the length of a string.
- Convert strings to numbers and numbers to strings.
- Use input to ask the user for a value to be used in the program.
- Employ various string methods to format string output, locate substrings, and replace parts of a string with a new string.
- Apply the index operator to extract a single character or group of characters from a string.