5. Python data is intelligent¶
Programming languages provide built-in functionalities in data to assist you.
Python data is intelligent: it can do things.
Print output (drag lower right corner to resize)
|
Activity: CodeLens 5.1 (cl_l33_5a_en)
5.1. find
method¶
find
method for strings
Print output (drag lower right corner to resize)
|
Activity: CodeLens 5.1.1 (cl_l33_5b_en)
10
from urllib.request import urlopen
URL_LOYALTY_PRICES = "https://api.allorigins.win/raw?url=http://beans.itcarlow.ie/prices-loyalty.html"
page = urlopen(URL_LOYALTY_PRICES)
text = page.read()
location = text.find(">$")
start = location + 2
end = start + 4
print(text[start:end])
Activity: 5.1.2 ActiveCode (ac_l33_5_en)
You have attempted 1 of 3 activities on this page