Page 91 -
P. 91
find, the right method
SOlUTion
These are some of the many built-in string methods that come with
Python. You were to match each method to what it does.
Method What the method does
text.endswith(".jpg") Return a copy of the string with all occurrences of one
substring replaced by another.
text.upper():
Return a copy of the string converted to lowercase.
text.lower(): Return the value True if the string has the given
substring at the beginning.
text.replace("tomorrow", "Tuesday"): Return the value True if the string has the given
substring at the end.
text.strip(): Return the first index value when the given substring is
found.
text.find("python"): Return a copy of the string with the leading and
trailing whitespace removed.
text.startswith("<HTML>")
Return a copy of the string converted to uppercase.
Which of the above methods do you need to use to locate the
price substring within the Beans’R’Us web page?
The “find()" method
56 Chapter 2