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.

Practice problems for string

Practice problems for string

- [Instructor] Here are some exercise problems for Python string. Remember that you can open this exercise file with Jupiter Notebook. Problem 1: initialize a new string, ABC, and store it in a new variable called a_string. For this one, I'm going to write a_string equals double quotes, or a single quotes, either way works, ABC. I'm going to run the cell with the play button at the top, and it should print ABC. And it does. Problem 2: from the string called b_string, defined below, retrieve and print the second character. To retrieve the second character, I'm going to write b_string square brackets 1. And I'll print it with the print function. And if I play the cell, it should print E. And it does. One thing to note here is that since a string is immutable, you won't be able to change its content. So if we write here b_string square brackets 1 equals, let's say A, it'll give us an error. And the error says "str…

Contents