0

I'm working on my first exercise from "Exercises in Programming Style" and I'm having great difficulty understanding the instructions. While reading an input file from Pride and Prejudice, one of the instructions says something that doesn't make any sense. What do the instructions mean when they said "Filter the characters, normalize to lowercase?" How do you filter the characters?

  • Sounds like it wants you to change them all to lowercase before doing whatever processing you're going to be doing on them. – MrMadsen Nov 04 '15 at 02:59
  • See [How do I verify that a string only has letters, numbers, underscores, and dashes](https://stackoverflow.com/questions/89909/how-do-i-verify-that-a-string-only-contains-letters-numbers-underscores-and-da/91572#91572) and then modify that to only allow alphanumeric characters (and then lowercase these) – LinkBerest Nov 04 '15 at 03:06
  • I should also note that the actual exercise is "Filter the characters, *identify the words*, and normalize them to lowercase" and the sample code included in the book does this using `.isalnum()` – LinkBerest Nov 04 '15 at 03:22

2 Answers2

0

Read it like this, "make sure each character is lower case". As in use a function to make sure each character is lower case.

jshaw1
  • 23
  • 4
0

When you process your characters, do something like:

>>> 'It is a truth universally acknowledged, that a single man in possession of a good fortune, must be in want of a wife.'.lower()

becomes:

'it is a truth universally acknowledged, that a single man in possession of a good fortune, must be in want of a wife.'
ergonaut
  • 6,929
  • 1
  • 17
  • 47