Emily Dickinson Experiment

Lets read some poety, and see what we can do...


1. Can you make the program count the number of occurences of a word?

2. Can you print out the lines which have a given word on it?

3. Can you find and display all the lines that have a repeated word?

4. Use the code from #1 to count the "was", and "was,". Why is there a difference? Consider the code below:

def removePunctuation(s):
  import string
  for c in string.punctuation:
    s= s.replace(c,"")
  return s

What does this do? Call this on every line and search for "was" now?

5. Consider the function s.lower(), where s is a string. What does it do? How might this be useful in the find repeated word code?

6. What would it take to create a list of all word, and the number of occurances?


Edit | Attach | Watch | Print version | History: r5 | r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r1 - 2018-09-29 - JimSkon
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback