Loading topic
upper, replace, and strip build a new string and hand it back. This chapter explains that rule, shows the bugs it causes, and gives the patterns you will use for the rest of the tut6 min readstr literals and indexing work, what lists and tuples are, and how to read simple if statements and for loops. It covers the in and not in operators on strings. These are the simplest way to ask whether one piece of text appears inside4 min readif statements and while loops work. It also assumes you have met the in operator, which answers "is this text present?". Here you will learn the methods that answer "where is it?": find, rfind, index,5 min readstr.count, the method that tells you how many times a substring appears in a string. It assumes you can read basic Python, know what str literals and indexing are, and understand if statements, for loops, lists, and tuples. It also assumes you have seen that string method5 min readif statements and for loops. You should also know from the earlier chapters that string methods return new values and never change the original string.4 min readlower, upper, capitalize, title, and swapcase. It assumes you know basic Python syntax, str literals and indexing, and how to read simple if statements and for loops. Earlier chapters covered the fact that strings are im4 min readin, find, count, and startswith work, and that lower() and upper() return new strings. It covers how to make those searches ignore case correctly, and why lower() is sometimes the wrong tool.5 min readstr.replace, the basic tool for substituting one piece of text with another. It assumes you know what str literals are, how to call a method, and how to read a simple for loop. It also builds on the previous chapters, where you saw that strings never change in place.4 min readstartswith and endswith, and read a list comprehension. Trimming is the most common cleanup step for text that comes from files, user input, or network response4 min readstr indexing, lists and tuples, and for loops. Earlier chapters showed that string methods return new strings. The methods here go a step further: they turn one string into a list or tuple of pieces, and turn pieces back into one string.5 min readis... methods on str. They answer yes/no questions about the characters in a string, such as "is this all digits?" or "is this only whitespace?". You should already know how to call string methods and write if statements, for loops and generator expressions. Earlier c4 min readstr.replace works and that strings are immutable, so every method returns a new string. You should also be comfortable reading dictionaries, tuples, and function definitions. By the end you will be able to build translation tables, use them to substitute and delet4 min readstr literals and indexing, and have met the individual methods strip, split, join, replace, casefold, translate, partition, and startswith. Here you combine them. The aim is to build short pipelines that turn messy input i6 min readstr methods from the earlier chapters (in, find, replace, split, strip, join). It also assumes you can read a short function and a for loop. You don't need prior regular expression experience. This chapter shows where the plain methods stop working a6 min read