So I have this code I wrote for my university's homework, and I feel like it should work, but it is not: ```py
import requests
import bs4
import sys
def find_attribute(url, html_element, attribute, output_file):
respond_object = requests.get(url)
soup_object = bs4.BeautifulSoup(respond_object.text, features="html.parser")
print(f"{url}, {html_element}, {attribute}, {output_file}")
if attribute == "final":
writeable_file = open(output_file, 'w')
writeable_file.write(soup_object.find(html_element)['final'])
writeable_file.close()
else:
desired_attribute = soup_object.find(html_element)[attribute]
new_search_list = str(desired_attribute).split(',')
find_attribute(str(new_search_list[0]), str(new_search_list[1]), str(new_search_list[2]), output_file)
if name == "main":
find_attribute(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
With this command to run it:
```python3 lab21.py https://cs111.byu.edu/lab/lab21/assets/webpage1.html p mediumhunt-checkpoint1 output.txt```
With this error:
Traceback (most recent call last):
File "/home/braxtenchenay/Programming/School/lab21/lab21.py", line 25, in <module>
find_attribute(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
File "/home/braxtenchenay/Programming/School/lab21/lab21.py", line 19, in find_attribute
desired_attribute = soup_object.find(html_element)[attribute]
File "/home/braxtenchenay/.var/app/com.visualstudio.code-oss/data/python/lib/python3.10/site-packages/bs4/element.py", line 1573, in getitem
return self.attrs[key]
KeyError: 'mediumhunt-checkpoint1'