From the course: Get Ready for Your Coding Interview

Unlock the full course today

Join today to access over 23,100 courses taught by industry experts.

Review of string in Python

Review of string in Python

[ Narrator] - Here's a quick review of String in Python. String is one of the most commonly used topics in coding interviews. So let's get right into it. The first thing to keep in mind is that String in Python is very similar to lists in Python. You can think of it sort of like a list that only stores characters instead of storing items of any types. One key difference here is, a list is mutable in Python, whereas a string is immutable. Which means, once a string is initialized, we won't be able to edit its content in the same way as we can edit list's content. To initialize a string you can just write S = "this is a string" with double quotes. Single quotes also work in Python, like S2 = 'this is also a string'. To retrieve characters from a string, just like with a list, you can just write S[0]. Which returns T or the first character of the string. Now, interestingly, the T here is in the string type as well. So in…

Contents