<commit_before>---
layout: post
author: elliott
categories:
  - exercise
title: "Chapter 8 MOAR Exercises"
link: https://elliott.trinket.io/inls-5-6-0-assignments#/more-lists-exercises/min-max-median
inclass: true
---

Some more lists exercises to keep you in the groove.

___

**Exercise 4**

Write a program that asks for a filename, opens it, and reads it line by line.
For each line, split the line into a list of words using the split function.
For each word, check to see if the word is already in a list. If the word is not in the list, add it to the list.

When the program completes, sort and print the resulting words in alphabetical order.

```
Enter file: romeo.txt
['Arise', 'But', 'It', 'Juliet', 'Who', 'already',
'and', 'breaks', 'east', 'envious', 'fair', 'grief',
'is', 'kill', 'light', 'moon', 'pale', 'sick', 'soft',<commit_msg>Update chapter 8 more link<commit_after>---
layout: post
author: elliott
categories:
  - exercise
title: "Chapter 8 MOAR Exercises"
link: https://elliott.trinket.io/inls-5-6-0-assignments#/more-lists-exercises/romeo
inclass: true
---

Some more lists exercises to keep you in the groove.

___

**Exercise 4**

Write a program that asks for a filename, opens it, and reads it line by line.
For each line, split the line into a list of words using the split function.
For each word, check to see if the word is already in a list. If the word is not in the list, add it to the list.

When the program completes, sort and print the resulting words in alphabetical order.

```
Enter file: romeo.txt
['Arise', 'But', 'It', 'Juliet', 'Who', 'already',
'and', 'breaks', 'east', 'envious', 'fair', 'grief',
'is', 'kill', 'light', 'moon', 'pale', 'sick', 'soft',
{'fraction_non_alphanumeric': 0.13294117647058823, 'fraction_numerical': 0.006470588235294118, 'mean_word_length': 4.233846153846154, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3817717', 'n_tokens_mistral': 578, 'n_tokens_neox': 555, 'n_words': 245}