Chapter 21. Print Formatting and Strings
Waaaayyyy back in chapter 1, you learned about the print statement. It was the first command you ever used in Python. You’ve also seen (in chapter 5) that you can put a comma at the end of a print statement to make Python keep printing the next thing on the same line. (At least, in Python 2. Not in Python 3.) You used that to make prompts for raw_input(), until you learned the shortcut of putting the prompt right in the raw_input() function.
In this chapter, we’re going to look at print formatting—ways to make your program’s output look the way you want it to. We’ll look at things like
- Starting new lines (and when you should do that)
- Spacing things out horizontally (and lining things up in columns) ...
Get Hello World! Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.