update scraper: sorted list first, then distinct set

This commit is contained in:
russell@unturf.com 2026-03-20 13:10:22 -04:00
parent afff26d65f
commit c46d9a39a6

View file

@ -120,15 +120,21 @@ Then check your answers below.
# strip tags, split on whitespace, find un* words
text = re.sub(r"<[^>]+>", " ", html)
words = text.split()
un_words = sorted(set(
un_words = sorted(
w.strip(".,;:!?\"'()[]").lower()
for w in words
if w.lower().startswith("un")
))
)
print(f"all occurrences ({len(un_words)}):")
for word in un_words:
print(word)
distinct = sorted(set(un_words))
print(f"\ndistinct words ({len(distinct)}):")
for word in distinct:
print(word)
|
**Define each word you find. Write your definitions before clicking the answer sheet.**