Unit: Unit 4: Strings, Lists, and Tuples • Interactive Practice
Interactive Python programming tutorial and practice in your browser.
# Locate the index positions of targets within a URL
web_url = "https://docs.python.org/3/library/functions.html"
# 1. Find the index where "python" begins
python_index = web_url.find("python")
# 2. Find the index of the file extension ".html"
html_index = web_url.find(".html")
# 3. Search for a non-existent word like "ruby"
ruby_index = web_url.find("ruby")
print("Index of 'python':", python_index)
print("Index of '.html':", html_index)
print("Index of 'ruby':", ruby_index)