Complete the code to print the main part of a web address.
url = 'https://www.example.com' main_part = url.split('[1]')[1] print(main_part)
The code splits the URL at '://', so the main part is after this.
Complete the code to check if a web address starts with 'https'.
url = 'https://secure.site' if url.[1]('https'): print('Secure connection')
The startswith method checks if the string begins with the given text.
Fix the error in the code that extracts the domain name from a URL.
url = 'http://openai.com' domain = url.split('[1]')[1] print(domain)
Splitting by '://' correctly separates the protocol from the domain.
Complete the code to create a dictionary of web pages and their status codes.
pages = ['home', 'about', 'contact'] status_codes = {page: 200 for page in pages if page [1] 'home'}
The dictionary comprehension uses ':' to map keys to values and '!=' to filter out 'home'.
Fill all three blanks to filter and transform a list of URLs.
urls = ['http://site1.com', 'https://site2.com', 'ftp://site3.com'] secure_sites = [url[1] for url in urls if url.[2]('https') and url.[3]('.com')]
We slice from index 8 to remove 'https://' prefix, check if URL starts with 'https', and ends with '.com'.
