Complete the code to identify the type of log entry.
if '404' in log_entry: log_type = '[1]'
The code checks if the log entry contains '404', which indicates an error (page not found).
Complete the code to extract the IP address from a log line.
ip_address = log_line.split(' ')[[1]]
The IP address is usually the first part of a log line, so index 0 after splitting by space.
Fix the error in the code to count how many times a specific URL appears in the log.
count = sum(1 for line in log if '[1]' in line)
The variable holding the URL to search is named 'url' in lowercase, so it must match exactly.
Fill both blanks to create a dictionary of URLs and their visit counts from the log.
url_counts = {line.split(' ')[[1]]: url_counts.get(line.split(' ')[[2]], 0) + 1 for line in log}The URL is typically the 7th element (index 6) in a common log format, so both blanks use 6 to extract the URL.
Fill all three blanks to filter log entries by status code and create a summary dictionary.
summary = {line.split(' ')[[1]]: int(line.split(' ')[[2]]) for line in log if line.split(' ')[[3]] == '200'}The URL is at index 6, the status code at index 8. We filter lines where the status code (index 8) equals '200'.