# Problem with deleting words from text [closed]

The task I need to do is to import a text book from here http://www.gutenberg.org/cache/epub/36/pg36.txt, then drop the last 20000 words from it and determine how many times the remaining words occur.

text = Drop[Import["http://www.gutenberg.org/cache/epub/36/pg36.txt", "Words"], -20000];

wordcounts = WordCounts[text];

top30 = Take[Transpose[{Keys@wordcounts, Values@wordcounts}], 30];
TableForm[top30, TableHeadings -> {None, {"Words", "Count"}}];


Why doesn't the above code work?

• Look up Drop[]. – J. M.'s technical difficulties Apr 2 '16 at 16:32
• Will it work with words? Or is it just going to drop characters instead of words? Sorry I am asking, can't check it up right now. – cubus14 Apr 2 '16 at 16:36
• ...maybe you should show the code you already have, so that we aren't left guessing. – J. M.'s technical difficulties Apr 2 '16 at 16:50
• Drop[Import["http://www.gutenberg.org/cache/epub/36/pg36.txt", "Words"], -20000]? – kglr Apr 2 '16 at 17:20
• WordCounts takes a single string as it 1st argument. You have given it a list of words. Since you already have a list, use Counts. – m_goldberg Apr 3 '16 at 15:29

text = Drop[Import["http://www.gutenberg.org/cache/epub/36/pg36.txt", "Words"], -20000];