In the last section of the course, we walk through variables and data types inside the Python programming language. And in this section I want to take one of those data types the string data type and I want to dissect it.
This section is going to be all about how to work with strings in Python. Now if you went through the variable module then you've already seen a number of ways to build strings. And in this introductory guide I want to show you the two different options that you have when it comes to creating a string in Python.
In this guide on Python strings we're going to learn how we can start changing and manipulating the case of a string. And this is going to introduce us to one of the most important concepts inside of programming which is the ability to call functions and methods on objects.
In this lesson, we're going to walk through how we can access values inside of strings and we're also going to work with ranges. Now don't worry if you do not know what those are you've never worked with them before. We're going to take a very preliminary view and then we're going to walk through some examples on how you can use ranges and how you can access string values.
So far in this section about string's we've focused on strings such as words and single line sentences. However, there are also times when you're going to have to work with multi-line strings and that's what we're going to discuss in this guide and multi-line strings in programming typically are called `Heredocs` and just so you can see exactly how that's spelled and how you'd use it. It's usually called a Heredoc every language is a little bit different but if you call a multi-line String a hear talk. Most other developers are going to know what you're saying. So it's one of the most common terms for that.
Continuing our discussion on how to use multiline strings in Python. One thing that you may have noticed in the last guide is that if we take this strip function away and run the code then it can be kind of hard to see that we have new line characters at the beginning and ending of this multiline String.
I'm very excited about the next few guides because these next few guides are going to go over string interpolation in Python. Now string interpolation is very big if you've never heard of it, it's a very scary word but it has a pretty basic goal and that is to give you the ability to run python code inside of strings.
In the last few guides we've discussed how we could work with string interpolation inside a python and I've mainly been showing you how to leverage string literals by being able to place curly brackets inside of the string and then simply placing variables inside of those and that is probably going to be your best bet and your best option for implementing string interpolation in your own Python projects.
A common process that you're going to need to perform when working with strings is being able to search inside of them. And I'm going to show you three different ways that we can perform this inside a python. And later on when we get to more advanced topics such as regular expressions we're going to come back and see how we can utilize regular expressions.
Continuing our journey on this string data type in Python. We're going to come back and discuss immutability if you remember back a few guides ago we talked about how strings in python are immutable which means that they can't be changed and that may sound like a weird concept because if you're coming from other programming languages it is incredibly easy to change the values of strings.
So far in the section on string's when we've talked about an index for a string we are talking about positive index values.
In previous guides, I showed how you could leverage the strip function in python to be able to get rid of excess spaces and specifically how to clear out beginning and end carriage returns.
This is going to be a fun guide on how to work with strings and specifically how we can implement what is called the partition function because this is something that I've found is very helpful. It's also going to give us a little bit of an introduction on collections in Python. Now we have an entire section dedicated to collections so we're not going to go into them in detail but you're going to see how strings can be connected and how they can generate their own collections.
In the last guide, we walked through how to use the partition function in python to be able to split a string into three elements and that can be very helpful whenever you want a single partition. But now we're going to extend this and we're going to talk about the split function in python and how we can use split to break our string into as many different elements as we want.
You may have noticed that many of the examples that I give throughout this course have really revolve around working with API's a huge reason for that is because one of the most modern ways of using python in development is to build and manage API requests.
devCamp does not support ancient browsers.
Install a modern version for best experience.