Manipulating Strings in Python
I want to learn Python, so I’ve been working through the Automate the Boring Stuff book by Al Sweigart. I’m documenting my journey on Medium to help retain what I’ve learned and maybe help some of you as well! Check out what I’ve completed so far here:
Chapter 6 in Automate the Boring Stuff covers strings. I honestly found this chapter quite fascinating. There is so much that can be done with strings simply by adding a method. They are also inherently set up as a list (each character has its own index) which makes slicing and dicing easy-peasy.
The beginning of the chapter covers escape characters. These make it possible to use certain characters in strings as well as help with formatting. They all start with a backslash (\).

Using the single quote or double quote escape character will allow for the use of quotes or apostrophes inside of a string.



These are pretty straightforward and are useful for formatting text as desired.
The next section covers strings as lists. I’ve provided a brief example of this, partly because I was curious to see how Python handles the escape characters when iterating through the string. It looks like the escape characters aren’t included which makes sense.

The rest of the chapter covers methods. There are a lot of different methods for strings, but I’m only going to cover a handful here. For a complete list check out W3Schools.
The methods upper() and lower() will return a new string where the entire string has been changed to either all uppercase or all lowercase.

The isupper() and islower() methods return True or False depending on if the string is all uppercase or all lowercase.

The split() and join() methods will split up a string into a list based on the specified delimiter, or join a list into a single string value, respectively. If the delimiter is left blank, it will split or join on spaces.

I’m working through the project for this chapter (it’s taking me longer than I had anticipated), and once that’s completed I’ll add a link to it here!
I’ve completed the project!
