Data Structure Selection

CS 65: Introduction to Computer Science I

What is a data structure?

A data structure is the data types, collections, and relationships used for organizing data for a particular programming tasks along with the specific operations that you utilize for that task

Core Python data structures

  • List
  • Tuple
  • Dictionary

We've also see than you can combine these in many ways for more complex data

  • CSV files: 2D list of lists
  • images: 2D stucture of tuples
  • Zipcode dataset: dictionary of dictionaries (which had lists inside of them!)

And you could think of more options like lists of dictionaries, 3D lists, etc.

There are also many more canonical data structures (covered in Intro to CS II) like stacks, queues, heaps, trees, and graphs that can be built or imported from modules.

How do you know which data structure to use for your problem?

Consider:

  1. What are the characteristics of the data I need to organize?
  2. What relationships exist in the data?
    • Is it ordered?
    • Are the mappings like key-value pairs?
  3. What computational tasks do I need to be able to execute with this data?

Think about:

  1. One way you could do it
  2. Additional ways you could do it

Decide which is best based on one or more of the following:

  • Which is easiest for you, the programmer, to implement
    • are there built-in types, modules, file formats available (e.g., csv and json)?
    • do you understand one way to do it more than the other?
    • will one of the ways take you longer to program?
  • Analyze how many operations will be needed for your task as the size of the data grows
    • Insert sort - nested loops, if you have $n$ elements, you hit each of them on the order of $n^2$ times
    • Find max - only visit each element once
    • Doing it formally: Intro to CS II and beyond
    • You can still think about it informally
  • Benchmarking - implement both methods and test how long each takes for your tasks

Example problem: word frequencies

Take a large piece of text, and count how many times each word is used

  • Used in several kinds of text analysis problems like sentiment analysis and author detection

Consider:

  • I need each word paired with its frequency (there is a mapping between the word and the frequency)
  • There is a potential order based alphabetically on the word or numerically on the frequency
  • I may want to display high-frequency words, look up the frequency of a specific word, compare word fequency between books

Ways I can think of to do it:

  • A dictionary where the word is the key and the frequency is the value
  • A list of tuples where the second entry in the tuple is the word and the first is the frequency
  • A 2D list - same as above but inner list instead of tuple
In [4]:
with open("aliceinwonderland.txt") as alicefile:
    alice_text = alicefile.read()
    
#print(alice_text)    
    
alice_text = alice_text[1435:145451] #getting rid of the project Gutenberg stuff at the beginning and end
alice_words = alice_text.split()

#print(alice_words)

word_frequencies_dict = {}

for word in alice_words:
    if word in word_frequencies_dict:
        word_frequencies_dict[word] += 1
    else:
        word_frequencies_dict[word] = 1

word_frequencies_dict
Out[4]:
{'CHAPTER': 12,
 'I.': 1,
 'Down': 1,
 'the': 1513,
 'Rabbit-Hole': 1,
 'Alice': 221,
 'was': 327,
 'beginning': 11,
 'to': 706,
 'get': 43,
 'very': 125,
 'tired': 7,
 'of': 492,
 'sitting': 10,
 'by': 53,
 'her': 204,
 'sister': 5,
 'on': 138,
 'bank,': 2,
 'and': 715,
 'having': 10,
 'nothing': 22,
 'do:': 1,
 'once': 18,
 'or': 68,
 'twice': 1,
 'she': 485,
 'had': 176,
 'peeped': 3,
 'into': 67,
 'book': 3,
 'reading,': 1,
 'but': 101,
 'it': 347,
 'no': 64,
 'pictures': 4,
 'conversations': 1,
 'in': 344,
 'it,': 38,
 '“and': 38,
 'what': 85,
 'is': 63,
 'use': 16,
 'a': 608,
 'book,”': 2,
 'thought': 63,
 '“without': 1,
 'conversations?”': 1,
 'So': 23,
 'considering': 3,
 'own': 9,
 'mind': 4,
 '(as': 2,
 'well': 27,
 'as': 237,
 'could,': 7,
 'for': 125,
 'hot': 4,
 'day': 11,
 'made': 29,
 'feel': 8,
 'sleepy': 3,
 'stupid),': 1,
 'whether': 11,
 'pleasure': 2,
 'making': 8,
 'daisy-chain': 1,
 'would': 68,
 'be': 137,
 'worth': 4,
 'trouble': 4,
 'getting': 21,
 'up': 81,
 'picking': 2,
 'daisies,': 1,
 'when': 66,
 'suddenly': 9,
 'White': 22,
 'Rabbit': 29,
 'with': 168,
 'pink': 1,
 'eyes': 18,
 'ran': 13,
 'close': 12,
 'her.': 13,
 'There': 19,
 'so': 103,
 '_very_': 13,
 'remarkable': 2,
 'that;': 1,
 'nor': 2,
 'did': 50,
 'think': 36,
 'much': 40,
 'out': 97,
 'way': 37,
 'hear': 14,
 'say': 35,
 'itself,': 4,
 '“Oh': 2,
 'dear!': 9,
 'Oh': 5,
 'I': 249,
 'shall': 21,
 'late!”': 1,
 '(when': 1,
 'over': 31,
 'afterwards,': 1,
 'occurred': 2,
 'that': 213,
 'ought': 13,
 'have': 73,
 'wondered': 1,
 'at': 196,
 'this,': 17,
 'time': 46,
 'all': 151,
 'seemed': 27,
 'quite': 53,
 'natural);': 1,
 'actually': 1,
 '_took': 1,
 'watch': 6,
 'its': 57,
 'waistcoat-pocket_,': 1,
 'looked': 45,
 'then': 50,
 'hurried': 11,
 'on,': 27,
 'started': 2,
 'feet,': 6,
 'flashed': 1,
 'across': 5,
 'never': 37,
 'before': 19,
 'seen': 12,
 'rabbit': 1,
 'either': 5,
 'waistcoat-pocket,': 1,
 'take': 18,
 'burning': 1,
 'curiosity,': 2,
 'field': 1,
 'after': 35,
 'fortunately': 1,
 'just': 43,
 'see': 47,
 'pop': 1,
 'down': 77,
 'large': 32,
 'rabbit-hole': 2,
 'under': 16,
 'hedge.': 1,
 'In': 5,
 'another': 21,
 'moment': 21,
 'went': 79,
 'how': 37,
 'world': 6,
 'again.': 16,
 'The': 89,
 'straight': 2,
 'like': 74,
 'tunnel': 1,
 'some': 47,
 'way,': 7,
 'dipped': 2,
 'down,': 12,
 'not': 103,
 'about': 84,
 'stopping': 1,
 'herself': 40,
 'found': 28,
 'falling': 2,
 'deep': 5,
 'well.': 2,
 'Either': 1,
 'deep,': 2,
 'fell': 6,
 'slowly,': 2,
 'plenty': 1,
 'look': 25,
 'wonder': 15,
 'going': 26,
 'happen': 5,
 'next.': 3,
 'First,': 4,
 'tried': 18,
 'make': 26,
 'coming': 5,
 'to,': 3,
 'too': 21,
 'dark': 3,
 'anything;': 2,
 'sides': 4,
 'well,': 1,
 'noticed': 7,
 'they': 108,
 'were': 82,
 'filled': 3,
 'cupboards': 2,
 'book-shelves;': 1,
 'here': 14,
 'there': 44,
 'saw': 13,
 'maps': 1,
 'hung': 1,
 'upon': 26,
 'pegs.': 1,
 'She': 33,
 'took': 23,
 'jar': 2,
 'from': 32,
 'one': 77,
 'shelves': 1,
 'passed;': 1,
 'labelled': 1,
 '“ORANGE': 1,
 'MARMALADE”,': 1,
 'great': 39,
 'disappointment': 1,
 'empty:': 1,
 'drop': 1,
 'fear': 4,
 'killing': 1,
 'somebody': 4,
 'underneath,': 1,
 'managed': 3,
 'put': 31,
 'past': 1,
 'it.': 15,
 '“Well!”': 1,
 'herself,': 31,
 '“after': 1,
 'such': 40,
 'fall': 6,
 'tumbling': 2,
 'stairs!': 1,
 'How': 9,
 'brave': 1,
 'they’ll': 4,
 'me': 46,
 'home!': 1,
 'Why,': 7,
 'wouldn’t': 12,
 'anything': 14,
 'even': 17,
 'if': 69,
 'off': 38,
 'top': 8,
 'house!”': 1,
 '(Which': 2,
 'likely': 4,
 'true.)': 1,
 'Down,': 2,
 'down.': 2,
 'Would': 3,
 '_never_': 2,
 'come': 22,
 'an': 52,
 'end?': 1,
 '“I': 119,
 'many': 12,
 'miles': 3,
 'I’ve': 20,
 'fallen': 4,
 'this': 86,
 'time?”': 1,
 'said': 416,
 'aloud.': 3,
 'must': 39,
 'somewhere': 1,
 'near': 14,
 'centre': 1,
 'earth.': 2,
 'Let': 6,
 'see:': 3,
 'four': 6,
 'thousand': 2,
 'think—”': 3,
 '(for,': 1,
 'you': 251,
 'see,': 11,
 'learnt': 2,
 'several': 4,
 'things': 19,
 'sort': 17,
 'lessons': 4,
 'schoolroom,': 1,
 'though': 6,
 'good': 23,
 'opportunity': 8,
 'showing': 2,
 'knowledge,': 1,
 'listen': 4,
 'her,': 18,
 'still': 12,
 'practice': 1,
 'over)': 1,
 '“—yes,': 1,
 'that’s': 13,
 'right': 20,
 'distance—but': 1,
 'Latitude': 2,
 'Longitude': 2,
 'got': 45,
 'to?”': 3,
 '(Alice': 4,
 'idea': 14,
 'was,': 14,
 'either,': 2,
 'nice': 5,
 'grand': 2,
 'words': 14,
 'say.)': 1,
 'Presently': 2,
 'began': 46,
 '_through_': 1,
 'earth!': 1,
 'funny': 3,
 'it’ll': 6,
 'seem': 7,
 'among': 12,
 'people': 10,
 'walk': 4,
 'their': 50,
 'heads': 7,
 'downward!': 1,
 'Antipathies,': 1,
 '(she': 9,
 'rather': 25,
 'glad': 11,
 '_was_': 5,
 'listening,': 2,
 'time,': 6,
 'didn’t': 11,
 'sound': 3,
 'word)': 1,
 '“—but': 1,
 'ask': 7,
 'them': 49,
 'name': 8,
 'country': 1,
 'is,': 16,
 'know.': 8,
 'Please,': 1,
 'Ma’am,': 1,
 'New': 1,
 'Zealand': 1,
 'Australia?”': 1,
 '(and': 1,
 'curtsey': 1,
 'spoke—fancy': 1,
 '_curtseying_': 1,
 'you’re': 15,
 'through': 12,
 'air!': 1,
 'Do': 5,
 'could': 63,
 'manage': 6,
 'it?)': 1,
 '“And': 17,
 'ignorant': 1,
 'little': 118,
 'girl': 3,
 'she’ll': 2,
 'asking!': 1,
 'No,': 4,
 'do': 46,
 'ask:': 1,
 'perhaps': 12,
 'written': 6,
 'somewhere.”': 1,
 'else': 8,
 'do,': 8,
 'soon': 23,
 'talking': 12,
 '“Dinah’ll': 1,
 'miss': 1,
 'to-night,': 1,
 'should': 27,
 'think!”': 1,
 '(Dinah': 1,
 'cat.)': 1,
 'hope': 3,
 'remember': 12,
 'saucer': 1,
 'milk': 1,
 'tea-time.': 1,
 'Dinah': 4,
 'my': 55,
 'wish': 21,
 'me!': 3,
 'are': 37,
 'mice': 3,
 'air,': 5,
 'I’m': 35,
 'afraid,': 2,
 'might': 27,
 'catch': 3,
 'bat,': 1,
 'mouse,': 3,
 'But': 15,
 'cats': 9,
 'eat': 16,
 'bats,': 1,
 'wonder?”': 3,
 'And': 49,
 'sleepy,': 1,
 'saying': 11,
 'dreamy': 1,
 '“Do': 8,
 'bats?': 1,
 'bats?”': 1,
 'sometimes,': 1,
 'bats': 1,
 'cats?”': 1,
 'for,': 2,
 'couldn’t': 9,
 'answer': 6,
 'question,': 4,
 'matter': 8,
 'which': 37,
 'felt': 23,
 'dozing': 1,
 'off,': 14,
 'begun': 6,
 'dream': 3,
 'walking': 5,
 'hand': 11,
 'Dinah,': 3,
 'earnestly,': 1,
 '“Now,': 4,
 'tell': 26,
 'truth:': 1,
 'ever': 16,
 'bat?”': 1,
 'suddenly,': 1,
 'thump!': 2,
 'came': 38,
 'heap': 1,
 'sticks': 1,
 'dry': 7,
 'leaves,': 2,
 'over.': 2,
 'bit': 8,
 'hurt,': 1,
 'jumped': 5,
 'feet': 11,
 'moment:': 1,
 'up,': 9,
 'overhead;': 1,
 'long': 29,
 'passage,': 2,
 'sight,': 4,
 'hurrying': 1,
 'lost:': 1,
 'away': 15,
 'wind,': 2,
 'say,': 5,
 'turned': 16,
 'corner,': 2,
 'ears': 4,
 'whiskers,': 1,
 'late': 3,
 'it’s': 25,
 'getting!”': 1,
 'behind': 12,
 'longer': 2,
 'seen:': 1,
 'long,': 1,
 'low': 7,
 'hall,': 5,
 'lit': 1,
 'row': 2,
 'lamps': 1,
 'hanging': 3,
 'roof.': 1,
 'doors': 2,
 'round': 30,
 'locked;': 1,
 'been': 36,
 'side': 12,
 'other,': 5,
 'trying': 11,
 'every': 12,
 'door,': 9,
 'walked': 10,
 'sadly': 2,
 'middle,': 3,
 'wondering': 7,
 'Suddenly': 1,
 'three-legged': 2,
 'table,': 5,
 'solid': 1,
 'glass;': 1,
 'except': 4,
 'tiny': 4,
 'golden': 7,
 'key,': 3,
 'Alice’s': 9,
 'first': 28,
 'belong': 1,
 'hall;': 1,
 'but,': 6,
 'alas!': 2,
 'locks': 1,
 'large,': 1,
 'key': 5,
 'small,': 1,
 'any': 36,
 'rate': 4,
 'open': 6,
 'them.': 2,
 'However,': 13,
 'second': 4,
 'round,': 7,
 'curtain': 1,
 'before,': 11,
 'door': 15,
 'fifteen': 1,
 'inches': 6,
 'high:': 3,
 'lock,': 1,
 'delight': 1,
 'fitted!': 1,
 'opened': 9,
 'led': 4,
 'small': 8,
 'larger': 3,
 'than': 23,
 'rat-hole:': 1,
 'knelt': 1,
 'along': 5,
 'passage': 1,
 'loveliest': 1,
 'garden': 4,
 'saw.': 1,
 'longed': 2,
 'wander': 1,
 'those': 9,
 'beds': 1,
 'bright': 7,
 'flowers': 2,
 'cool': 2,
 'fountains,': 1,
 'head': 29,
 'doorway;': 1,
 'go': 38,
 'through,”': 1,
 'poor': 25,
 'Alice,': 76,
 '“it': 5,
 'without': 24,
 'shoulders.': 1,
 'Oh,': 3,
 'shut': 4,
 'telescope!': 1,
 'only': 43,
 'knew': 13,
 'begin.”': 3,
 'For,': 1,
 'out-of-the-way': 3,
 'happened': 3,
 'lately,': 1,
 'few': 9,
 'indeed': 3,
 'really': 9,
 'impossible.': 1,
 'waiting': 7,
 'back': 29,
 'half': 21,
 'hoping': 3,
 'find': 20,
 'rules': 3,
 'shutting': 2,
 'telescopes:': 1,
 'bottle': 7,
 '(“which': 1,
 'certainly': 8,
 'before,”': 3,
 'Alice,)': 2,
 'neck': 6,
 'paper': 3,
 'label,': 1,
 '“DRINK': 2,
 'ME,”': 2,
 'beautifully': 2,
 'printed': 1,
 'letters.': 1,
 'It': 15,
 '“Drink': 1,
 'me,”': 5,
 'wise': 2,
 '_that_': 6,
 'hurry.': 3,
 '“No,': 9,
 'I’ll': 23,
 'first,”': 2,
 'said,': 26,
 'marked': 5,
 '‘_poison_’': 1,
 'not”;': 1,
 'read': 9,
 'histories': 1,
 'children': 5,
 'who': 48,
 'burnt,': 1,
 'eaten': 1,
 'wild': 2,
 'beasts': 1,
 'other': 26,
 'unpleasant': 2,
 'things,': 2,
 'because': 11,
 '_would_': 5,
 'simple': 5,
 'friends': 2,
 'taught': 4,
 'them:': 1,
 'as,': 2,
 'red-hot': 1,
 'poker': 1,
 'will': 23,
 'burn': 2,
 'hold': 6,
 'long;': 1,
 'cut': 5,
 'your': 53,
 'finger': 3,
 'deeply': 1,
 'knife,': 1,
 'usually': 2,
 'bleeds;': 1,
 'forgotten': 6,
 'that,': 5,
 'drink': 4,
 '“poison,”': 2,
 'almost': 6,
 'certain': 2,
 'disagree': 1,
 'you,': 25,
 'sooner': 2,
 'later.': 1,
 '_not_': 5,
 'ventured': 4,
 'taste': 2,
 'finding': 3,
 'nice,': 1,
 '(it': 4,
 'had,': 1,
 'fact,': 4,
 'mixed': 2,
 'flavour': 1,
 'cherry-tart,': 1,
 'custard,': 1,
 'pine-apple,': 1,
 'roast': 1,
 'turkey,': 1,
 'toffee,': 1,
 'buttered': 1,
 'toast,)': 1,
 'finished': 7,
 'off.': 5,
 '*': 60,
 '“What': 33,
 'curious': 16,
 'feeling!”': 1,
 'Alice;': 16,
 'telescope.”': 1,
 'indeed:': 1,
 'now': 23,
 'ten': 5,
 'high,': 3,
 'face': 7,
 'brightened': 2,
 'size': 6,
 'lovely': 2,
 'garden.': 3,
 'however,': 6,
 'waited': 9,
 'minutes': 7,
 'shrink': 1,
 'further:': 1,
 'nervous': 4,
 'this;': 2,
 '“for': 6,
 'end,': 1,
 'know,”': 8,
 '“in': 3,
 'altogether,': 2,
 'candle.': 1,
 'then?”': 1,
 'fancy': 3,
 'flame': 1,
 'candle': 2,
 'blown': 1,
 'out,': 13,
 'thing.': 1,
 'After': 5,
 'while,': 4,
 'more': 38,
 'happened,': 2,
 'decided': 3,
 'once;': 1,
 'alas': 1,
 'Alice!': 3,
 'table': 7,
 'possibly': 3,
 'reach': 4,
 'it:': 9,
 'plainly': 1,
 'glass,': 2,
 'best': 7,
 'climb': 1,
 'legs': 3,
 'slippery;': 1,
 'trying,': 1,
 'thing': 35,
 'sat': 17,
 'cried.': 2,
 '“Come,': 9,
 'there’s': 15,
 'crying': 2,
 'that!”': 7,
 'sharply;': 1,
 'advise': 1,
 'leave': 7,
 'minute!”': 1,
 'generally': 5,
 'gave': 15,
 'advice,': 1,
 '(though': 1,
 'seldom': 1,
 'followed': 8,
 'it),': 2,
 'sometimes': 4,
 'scolded': 1,
 'severely': 3,
 'bring': 2,
 'tears': 4,
 'eyes;': 1,
 'remembered': 5,
 'box': 3,
 'cheated': 1,
 'game': 6,
 'croquet': 3,
 'playing': 2,
 'against': 9,
 'child': 3,
 'fond': 3,
 'pretending': 1,
 'two': 20,
 'people.': 1,
 '“But': 19,
 'now,”': 4,
 '“to': 4,
 'pretend': 1,
 'people!': 1,
 'hardly': 11,
 'enough': 10,
 'left': 13,
 '_one_': 2,
 'respectable': 1,
 'person!”': 1,
 'Soon': 1,
 'eye': 4,
 'glass': 4,
 'lying': 8,
 'table:': 1,
 'cake,': 2,
 '“EAT': 1,
 'ME”': 1,
 'currants.': 1,
 '“Well,': 20,
 'it,”': 18,
 'makes': 11,
 'grow': 13,
 'larger,': 3,
 'can': 27,
 'key;': 1,
 'smaller,': 3,
 'creep': 1,
 'door;': 1,
 'garden,': 5,
 'don’t': 48,
 'care': 4,
 'happens!”': 1,
 'ate': 1,
 'bit,': 2,
 'anxiously': 13,
 '“Which': 3,
 'way?': 1,
 'Which': 3,
 'way?”,': 1,
 'holding': 2,
 'growing,': 4,
 'surprised': 6,
 'remained': 3,
 'same': 21,
 'size:': 3,
 'sure,': 2,
 'happens': 2,
 'eats': 1,
 'expecting': 3,
 'happen,': 1,
 'dull': 2,
 'stupid': 1,
 'life': 2,
 'common': 1,
 'way.': 3,
 'set': 14,
 'work,': 1,
 'cake.': 1,
 'II.': 1,
 'Pool': 1,
 'Tears': 1,
 '“Curiouser': 1,
 'curiouser!”': 1,
 'cried': 18,
 'surprised,': 1,
 'forgot': 2,
 'speak': 8,
 'English);': 1,
 '“now': 1,
 'opening': 3,
 'largest': 1,
 'telescope': 1,
 'was!': 1,
 'Good-bye,': 1,
 'feet!”': 1,
 '(for': 1,
 'far': 9,
 'off).': 1,
 '“Oh,': 19,
 'shoes': 5,
 'stockings': 1,
 'now,': 6,
 'dears?': 1,
 'sure': 16,
 '_I_': 13,
 'shan’t': 4,
 'able!': 1,
 'deal': 11,
 'myself': 2,
 'you:': 1,
 'can;—but': 1,
 'kind': 6,
 'them,”': 3,
 '“or': 5,
 'won’t': 21,
 'want': 9,
 'go!': 1,
 'give': 9,
 'new': 4,
 'pair': 5,
 'boots': 3,
 'Christmas.”': 1,
 'planning': 1,
 '“They': 9,
 'carrier,”': 1,
 'thought;': 1,
 'seem,': 1,
 'sending': 2,
 'presents': 2,
 'one’s': 1,
 'feet!': 1,
 'odd': 1,
 'directions': 1,
 'look!': 1,
 '_Alice’s': 1,
 'Right': 1,
 'Foot,': 1,
 'Esq.,': 1,
 'Hearthrug,': 1,
 'Fender,_': 1,
 '(_with': 1,
 'love_).': 1,
 'dear,': 6,
 'nonsense': 1,
 'talking!”': 1,
 'Just': 5,
 'struck': 2,
 'roof': 5,
 'hall:': 1,
 'fact': 2,
 'nine': 4,
 'door.': 2,
 'Poor': 1,
 'side,': 3,
 'eye;': 2,
 'hopeless': 1,
 'ever:': 1,
 'cry': 3,
 '“You': 32,
 'ashamed': 2,
 'yourself,”': 1,
 '“a': 2,
 'you,”': 6,
 'this),': 1,
 'way!': 1,
 'Stop': 1,
 'moment,': 5,
 'you!”': 3,
 'same,': 2,
 'shedding': 1,
 'gallons': 1,
 'tears,': 3,
 'until': 4,
 'pool': 6,
 'reaching': 1,
 'hall.': 1,
 'heard': 29,
 'pattering': 3,
 'distance,': 4,
 'hastily': 7,
 'dried': 1,
 'coming.': 2,
 'returning,': 1,
 'splendidly': 1,
 'dressed,': 1,
 'white': 6,
 'kid': 5,
 'gloves': 5,
 'fan': 8,
 'other:': 3,
 'he': 94,
 'trotting': 2,
 'hurry,': 1,
 'muttering': 3,
 'himself': 4,
 'came,': 2,
 '“Oh!': 2,
 'Duchess,': 8,
 'Duchess!': 3,
 'Oh!': 1,
 'savage': 3,
 'kept': 13,
 'waiting!”': 1,
 'desperate': 1,
 'ready': 7,
 'help': 9,
 'one;': 2,
 'so,': 7,
 'began,': 6,
 'low,': 6,
 'timid': 3,
 'voice,': 15,
 '“If': 14,
 'please,': 3,
 'sir—”': 1,
 'violently,': 2,
 'dropped': 4,
 'fan,': 1,
 'skurried': 1,
 'darkness': 1,
 'hard': 8,
 'go.': 1,
 'gloves,': 3,
 'and,': 19,
 'hall': 1,
 'hot,': 1,
 'fanning': 1,
 'talking:': 1,
 '“Dear,': 1,
 'queer': 9,
 'everything': 9,
 'to-day!': 1,
 'yesterday': 2,
 'usual.': 2,
 'changed': 7,
 'night?': 1,
 'think:': 1,
 'morning?': 1,
 'feeling': 6,
 'different.': 1,
 'next': 20,
 'question': 7,
 'Who': 6,
 'am': 13,
 'I?': 1,
 'Ah,': 1,
 '_that’s_': 3,
 'puzzle!”': 1,
 'thinking': 10,
 'age': 2,
 '“I’m': 19,
 'Ada,”': 1,
 'hair': 5,
 'goes': 7,
 'ringlets,': 1,
 'mine': 3,
 'doesn’t': 16,
 'ringlets': 1,
 'all;': 2,
 'can’t': 27,
 'Mabel,': 2,
 'know': 45,
 'sorts': 3,
 'she,': 4,
 ...}
In [5]:
with open("aliceinwonderland.txt") as alicefile:
    alice_text = alicefile.read()
    
alice_text = alice_text[1435:145451]
alice_words = alice_text.split()

word_frequencies_2dlist = []

for word in alice_words:
    
    #search the list of tuples looking for this word
    found_word_in_list = False
    for freq in word_frequencies_2dlist:
        
        #if I find it, add one onto its counter and
        #flag that we found it
        if word == freq[1]:
            freq[0] += 1
            found_word_in_list = True
            
    #didn't find it in the loop above, so we add a new tuple
    #for the word with frequency 1
    if not found_word_in_list:
        word_frequencies_2dlist.append([1,word])

word_frequencies_2dlist
Out[5]:
[[12, 'CHAPTER'],
 [1, 'I.'],
 [1, 'Down'],
 [1513, 'the'],
 [1, 'Rabbit-Hole'],
 [221, 'Alice'],
 [327, 'was'],
 [11, 'beginning'],
 [706, 'to'],
 [43, 'get'],
 [125, 'very'],
 [7, 'tired'],
 [492, 'of'],
 [10, 'sitting'],
 [53, 'by'],
 [204, 'her'],
 [5, 'sister'],
 [138, 'on'],
 [2, 'bank,'],
 [715, 'and'],
 [10, 'having'],
 [22, 'nothing'],
 [1, 'do:'],
 [18, 'once'],
 [68, 'or'],
 [1, 'twice'],
 [485, 'she'],
 [176, 'had'],
 [3, 'peeped'],
 [67, 'into'],
 [3, 'book'],
 [1, 'reading,'],
 [101, 'but'],
 [347, 'it'],
 [64, 'no'],
 [4, 'pictures'],
 [1, 'conversations'],
 [344, 'in'],
 [38, 'it,'],
 [38, '“and'],
 [85, 'what'],
 [63, 'is'],
 [16, 'use'],
 [608, 'a'],
 [2, 'book,”'],
 [63, 'thought'],
 [1, '“without'],
 [1, 'conversations?”'],
 [23, 'So'],
 [3, 'considering'],
 [9, 'own'],
 [4, 'mind'],
 [2, '(as'],
 [27, 'well'],
 [237, 'as'],
 [7, 'could,'],
 [125, 'for'],
 [4, 'hot'],
 [11, 'day'],
 [29, 'made'],
 [8, 'feel'],
 [3, 'sleepy'],
 [1, 'stupid),'],
 [11, 'whether'],
 [2, 'pleasure'],
 [8, 'making'],
 [1, 'daisy-chain'],
 [68, 'would'],
 [137, 'be'],
 [4, 'worth'],
 [4, 'trouble'],
 [21, 'getting'],
 [81, 'up'],
 [2, 'picking'],
 [1, 'daisies,'],
 [66, 'when'],
 [9, 'suddenly'],
 [22, 'White'],
 [29, 'Rabbit'],
 [168, 'with'],
 [1, 'pink'],
 [18, 'eyes'],
 [13, 'ran'],
 [12, 'close'],
 [13, 'her.'],
 [19, 'There'],
 [103, 'so'],
 [13, '_very_'],
 [2, 'remarkable'],
 [1, 'that;'],
 [2, 'nor'],
 [50, 'did'],
 [36, 'think'],
 [40, 'much'],
 [97, 'out'],
 [37, 'way'],
 [14, 'hear'],
 [35, 'say'],
 [4, 'itself,'],
 [2, '“Oh'],
 [9, 'dear!'],
 [5, 'Oh'],
 [249, 'I'],
 [21, 'shall'],
 [1, 'late!”'],
 [1, '(when'],
 [31, 'over'],
 [1, 'afterwards,'],
 [2, 'occurred'],
 [213, 'that'],
 [13, 'ought'],
 [73, 'have'],
 [1, 'wondered'],
 [196, 'at'],
 [17, 'this,'],
 [46, 'time'],
 [151, 'all'],
 [27, 'seemed'],
 [53, 'quite'],
 [1, 'natural);'],
 [1, 'actually'],
 [1, '_took'],
 [6, 'watch'],
 [57, 'its'],
 [1, 'waistcoat-pocket_,'],
 [45, 'looked'],
 [50, 'then'],
 [11, 'hurried'],
 [27, 'on,'],
 [2, 'started'],
 [6, 'feet,'],
 [1, 'flashed'],
 [5, 'across'],
 [37, 'never'],
 [19, 'before'],
 [12, 'seen'],
 [1, 'rabbit'],
 [5, 'either'],
 [1, 'waistcoat-pocket,'],
 [18, 'take'],
 [1, 'burning'],
 [2, 'curiosity,'],
 [1, 'field'],
 [35, 'after'],
 [1, 'fortunately'],
 [43, 'just'],
 [47, 'see'],
 [1, 'pop'],
 [77, 'down'],
 [32, 'large'],
 [2, 'rabbit-hole'],
 [16, 'under'],
 [1, 'hedge.'],
 [5, 'In'],
 [21, 'another'],
 [21, 'moment'],
 [79, 'went'],
 [37, 'how'],
 [6, 'world'],
 [16, 'again.'],
 [89, 'The'],
 [2, 'straight'],
 [74, 'like'],
 [1, 'tunnel'],
 [47, 'some'],
 [7, 'way,'],
 [2, 'dipped'],
 [12, 'down,'],
 [103, 'not'],
 [84, 'about'],
 [1, 'stopping'],
 [40, 'herself'],
 [28, 'found'],
 [2, 'falling'],
 [5, 'deep'],
 [2, 'well.'],
 [1, 'Either'],
 [2, 'deep,'],
 [6, 'fell'],
 [2, 'slowly,'],
 [1, 'plenty'],
 [25, 'look'],
 [15, 'wonder'],
 [26, 'going'],
 [5, 'happen'],
 [3, 'next.'],
 [4, 'First,'],
 [18, 'tried'],
 [26, 'make'],
 [5, 'coming'],
 [3, 'to,'],
 [21, 'too'],
 [3, 'dark'],
 [2, 'anything;'],
 [4, 'sides'],
 [1, 'well,'],
 [7, 'noticed'],
 [108, 'they'],
 [82, 'were'],
 [3, 'filled'],
 [2, 'cupboards'],
 [1, 'book-shelves;'],
 [14, 'here'],
 [44, 'there'],
 [13, 'saw'],
 [1, 'maps'],
 [1, 'hung'],
 [26, 'upon'],
 [1, 'pegs.'],
 [33, 'She'],
 [23, 'took'],
 [2, 'jar'],
 [32, 'from'],
 [77, 'one'],
 [1, 'shelves'],
 [1, 'passed;'],
 [1, 'labelled'],
 [1, '“ORANGE'],
 [1, 'MARMALADE”,'],
 [39, 'great'],
 [1, 'disappointment'],
 [1, 'empty:'],
 [1, 'drop'],
 [4, 'fear'],
 [1, 'killing'],
 [4, 'somebody'],
 [1, 'underneath,'],
 [3, 'managed'],
 [31, 'put'],
 [1, 'past'],
 [15, 'it.'],
 [1, '“Well!”'],
 [31, 'herself,'],
 [1, '“after'],
 [40, 'such'],
 [6, 'fall'],
 [2, 'tumbling'],
 [1, 'stairs!'],
 [9, 'How'],
 [1, 'brave'],
 [4, 'they’ll'],
 [46, 'me'],
 [1, 'home!'],
 [7, 'Why,'],
 [12, 'wouldn’t'],
 [14, 'anything'],
 [17, 'even'],
 [69, 'if'],
 [38, 'off'],
 [8, 'top'],
 [1, 'house!”'],
 [2, '(Which'],
 [4, 'likely'],
 [1, 'true.)'],
 [2, 'Down,'],
 [2, 'down.'],
 [3, 'Would'],
 [2, '_never_'],
 [22, 'come'],
 [52, 'an'],
 [1, 'end?'],
 [119, '“I'],
 [12, 'many'],
 [3, 'miles'],
 [20, 'I’ve'],
 [4, 'fallen'],
 [86, 'this'],
 [1, 'time?”'],
 [416, 'said'],
 [3, 'aloud.'],
 [39, 'must'],
 [1, 'somewhere'],
 [14, 'near'],
 [1, 'centre'],
 [2, 'earth.'],
 [6, 'Let'],
 [3, 'see:'],
 [6, 'four'],
 [2, 'thousand'],
 [3, 'think—”'],
 [1, '(for,'],
 [251, 'you'],
 [11, 'see,'],
 [2, 'learnt'],
 [4, 'several'],
 [19, 'things'],
 [17, 'sort'],
 [4, 'lessons'],
 [1, 'schoolroom,'],
 [6, 'though'],
 [23, 'good'],
 [8, 'opportunity'],
 [2, 'showing'],
 [1, 'knowledge,'],
 [4, 'listen'],
 [18, 'her,'],
 [12, 'still'],
 [1, 'practice'],
 [1, 'over)'],
 [1, '“—yes,'],
 [13, 'that’s'],
 [20, 'right'],
 [1, 'distance—but'],
 [2, 'Latitude'],
 [2, 'Longitude'],
 [45, 'got'],
 [3, 'to?”'],
 [4, '(Alice'],
 [14, 'idea'],
 [14, 'was,'],
 [2, 'either,'],
 [5, 'nice'],
 [2, 'grand'],
 [14, 'words'],
 [1, 'say.)'],
 [2, 'Presently'],
 [46, 'began'],
 [1, '_through_'],
 [1, 'earth!'],
 [3, 'funny'],
 [6, 'it’ll'],
 [7, 'seem'],
 [12, 'among'],
 [10, 'people'],
 [4, 'walk'],
 [50, 'their'],
 [7, 'heads'],
 [1, 'downward!'],
 [1, 'Antipathies,'],
 [9, '(she'],
 [25, 'rather'],
 [11, 'glad'],
 [5, '_was_'],
 [2, 'listening,'],
 [6, 'time,'],
 [11, 'didn’t'],
 [3, 'sound'],
 [1, 'word)'],
 [1, '“—but'],
 [7, 'ask'],
 [49, 'them'],
 [8, 'name'],
 [1, 'country'],
 [16, 'is,'],
 [8, 'know.'],
 [1, 'Please,'],
 [1, 'Ma’am,'],
 [1, 'New'],
 [1, 'Zealand'],
 [1, 'Australia?”'],
 [1, '(and'],
 [1, 'curtsey'],
 [1, 'spoke—fancy'],
 [1, '_curtseying_'],
 [15, 'you’re'],
 [12, 'through'],
 [1, 'air!'],
 [5, 'Do'],
 [63, 'could'],
 [6, 'manage'],
 [1, 'it?)'],
 [17, '“And'],
 [1, 'ignorant'],
 [118, 'little'],
 [3, 'girl'],
 [2, 'she’ll'],
 [1, 'asking!'],
 [4, 'No,'],
 [46, 'do'],
 [1, 'ask:'],
 [12, 'perhaps'],
 [6, 'written'],
 [1, 'somewhere.”'],
 [8, 'else'],
 [8, 'do,'],
 [23, 'soon'],
 [12, 'talking'],
 [1, '“Dinah’ll'],
 [1, 'miss'],
 [1, 'to-night,'],
 [27, 'should'],
 [1, 'think!”'],
 [1, '(Dinah'],
 [1, 'cat.)'],
 [3, 'hope'],
 [12, 'remember'],
 [1, 'saucer'],
 [1, 'milk'],
 [1, 'tea-time.'],
 [4, 'Dinah'],
 [55, 'my'],
 [21, 'wish'],
 [3, 'me!'],
 [37, 'are'],
 [3, 'mice'],
 [5, 'air,'],
 [35, 'I’m'],
 [2, 'afraid,'],
 [27, 'might'],
 [3, 'catch'],
 [1, 'bat,'],
 [3, 'mouse,'],
 [15, 'But'],
 [9, 'cats'],
 [16, 'eat'],
 [1, 'bats,'],
 [3, 'wonder?”'],
 [49, 'And'],
 [1, 'sleepy,'],
 [11, 'saying'],
 [1, 'dreamy'],
 [8, '“Do'],
 [1, 'bats?'],
 [1, 'bats?”'],
 [1, 'sometimes,'],
 [1, 'bats'],
 [1, 'cats?”'],
 [2, 'for,'],
 [9, 'couldn’t'],
 [6, 'answer'],
 [4, 'question,'],
 [8, 'matter'],
 [37, 'which'],
 [23, 'felt'],
 [1, 'dozing'],
 [14, 'off,'],
 [6, 'begun'],
 [3, 'dream'],
 [5, 'walking'],
 [11, 'hand'],
 [3, 'Dinah,'],
 [1, 'earnestly,'],
 [4, '“Now,'],
 [26, 'tell'],
 [1, 'truth:'],
 [16, 'ever'],
 [1, 'bat?”'],
 [1, 'suddenly,'],
 [2, 'thump!'],
 [38, 'came'],
 [1, 'heap'],
 [1, 'sticks'],
 [7, 'dry'],
 [2, 'leaves,'],
 [2, 'over.'],
 [8, 'bit'],
 [1, 'hurt,'],
 [5, 'jumped'],
 [11, 'feet'],
 [1, 'moment:'],
 [9, 'up,'],
 [1, 'overhead;'],
 [29, 'long'],
 [2, 'passage,'],
 [4, 'sight,'],
 [1, 'hurrying'],
 [1, 'lost:'],
 [15, 'away'],
 [2, 'wind,'],
 [5, 'say,'],
 [16, 'turned'],
 [2, 'corner,'],
 [4, 'ears'],
 [1, 'whiskers,'],
 [3, 'late'],
 [25, 'it’s'],
 [1, 'getting!”'],
 [12, 'behind'],
 [2, 'longer'],
 [1, 'seen:'],
 [1, 'long,'],
 [7, 'low'],
 [5, 'hall,'],
 [1, 'lit'],
 [2, 'row'],
 [1, 'lamps'],
 [3, 'hanging'],
 [1, 'roof.'],
 [2, 'doors'],
 [30, 'round'],
 [1, 'locked;'],
 [36, 'been'],
 [12, 'side'],
 [5, 'other,'],
 [11, 'trying'],
 [12, 'every'],
 [9, 'door,'],
 [10, 'walked'],
 [2, 'sadly'],
 [3, 'middle,'],
 [7, 'wondering'],
 [1, 'Suddenly'],
 [2, 'three-legged'],
 [5, 'table,'],
 [1, 'solid'],
 [1, 'glass;'],
 [4, 'except'],
 [4, 'tiny'],
 [7, 'golden'],
 [3, 'key,'],
 [9, 'Alice’s'],
 [28, 'first'],
 [1, 'belong'],
 [1, 'hall;'],
 [6, 'but,'],
 [2, 'alas!'],
 [1, 'locks'],
 [1, 'large,'],
 [5, 'key'],
 [1, 'small,'],
 [36, 'any'],
 [4, 'rate'],
 [6, 'open'],
 [2, 'them.'],
 [13, 'However,'],
 [4, 'second'],
 [7, 'round,'],
 [1, 'curtain'],
 [11, 'before,'],
 [15, 'door'],
 [1, 'fifteen'],
 [6, 'inches'],
 [3, 'high:'],
 [1, 'lock,'],
 [1, 'delight'],
 [1, 'fitted!'],
 [9, 'opened'],
 [4, 'led'],
 [8, 'small'],
 [3, 'larger'],
 [23, 'than'],
 [1, 'rat-hole:'],
 [1, 'knelt'],
 [5, 'along'],
 [1, 'passage'],
 [1, 'loveliest'],
 [4, 'garden'],
 [1, 'saw.'],
 [2, 'longed'],
 [1, 'wander'],
 [9, 'those'],
 [1, 'beds'],
 [7, 'bright'],
 [2, 'flowers'],
 [2, 'cool'],
 [1, 'fountains,'],
 [29, 'head'],
 [1, 'doorway;'],
 [38, 'go'],
 [1, 'through,”'],
 [25, 'poor'],
 [76, 'Alice,'],
 [5, '“it'],
 [24, 'without'],
 [1, 'shoulders.'],
 [3, 'Oh,'],
 [4, 'shut'],
 [1, 'telescope!'],
 [43, 'only'],
 [13, 'knew'],
 [3, 'begin.”'],
 [1, 'For,'],
 [3, 'out-of-the-way'],
 [3, 'happened'],
 [1, 'lately,'],
 [9, 'few'],
 [3, 'indeed'],
 [9, 'really'],
 [1, 'impossible.'],
 [7, 'waiting'],
 [29, 'back'],
 [21, 'half'],
 [3, 'hoping'],
 [20, 'find'],
 [3, 'rules'],
 [2, 'shutting'],
 [1, 'telescopes:'],
 [7, 'bottle'],
 [1, '(“which'],
 [8, 'certainly'],
 [3, 'before,”'],
 [2, 'Alice,)'],
 [6, 'neck'],
 [3, 'paper'],
 [1, 'label,'],
 [2, '“DRINK'],
 [2, 'ME,”'],
 [2, 'beautifully'],
 [1, 'printed'],
 [1, 'letters.'],
 [15, 'It'],
 [1, '“Drink'],
 [5, 'me,”'],
 [2, 'wise'],
 [6, '_that_'],
 [3, 'hurry.'],
 [9, '“No,'],
 [23, 'I’ll'],
 [2, 'first,”'],
 [26, 'said,'],
 [5, 'marked'],
 [1, '‘_poison_’'],
 [1, 'not”;'],
 [9, 'read'],
 [1, 'histories'],
 [5, 'children'],
 [48, 'who'],
 [1, 'burnt,'],
 [1, 'eaten'],
 [2, 'wild'],
 [1, 'beasts'],
 [26, 'other'],
 [2, 'unpleasant'],
 [2, 'things,'],
 [11, 'because'],
 [5, '_would_'],
 [5, 'simple'],
 [2, 'friends'],
 [4, 'taught'],
 [1, 'them:'],
 [2, 'as,'],
 [1, 'red-hot'],
 [1, 'poker'],
 [23, 'will'],
 [2, 'burn'],
 [6, 'hold'],
 [1, 'long;'],
 [5, 'cut'],
 [53, 'your'],
 [3, 'finger'],
 [1, 'deeply'],
 [1, 'knife,'],
 [2, 'usually'],
 [1, 'bleeds;'],
 [6, 'forgotten'],
 [5, 'that,'],
 [4, 'drink'],
 [2, '“poison,”'],
 [6, 'almost'],
 [2, 'certain'],
 [1, 'disagree'],
 [25, 'you,'],
 [2, 'sooner'],
 [1, 'later.'],
 [5, '_not_'],
 [4, 'ventured'],
 [2, 'taste'],
 [3, 'finding'],
 [1, 'nice,'],
 [4, '(it'],
 [1, 'had,'],
 [4, 'fact,'],
 [2, 'mixed'],
 [1, 'flavour'],
 [1, 'cherry-tart,'],
 [1, 'custard,'],
 [1, 'pine-apple,'],
 [1, 'roast'],
 [1, 'turkey,'],
 [1, 'toffee,'],
 [1, 'buttered'],
 [1, 'toast,)'],
 [7, 'finished'],
 [5, 'off.'],
 [60, '*'],
 [33, '“What'],
 [16, 'curious'],
 [1, 'feeling!”'],
 [16, 'Alice;'],
 [1, 'telescope.”'],
 [1, 'indeed:'],
 [23, 'now'],
 [5, 'ten'],
 [3, 'high,'],
 [7, 'face'],
 [2, 'brightened'],
 [6, 'size'],
 [2, 'lovely'],
 [3, 'garden.'],
 [6, 'however,'],
 [9, 'waited'],
 [7, 'minutes'],
 [1, 'shrink'],
 [1, 'further:'],
 [4, 'nervous'],
 [2, 'this;'],
 [6, '“for'],
 [1, 'end,'],
 [8, 'know,”'],
 [3, '“in'],
 [2, 'altogether,'],
 [1, 'candle.'],
 [1, 'then?”'],
 [3, 'fancy'],
 [1, 'flame'],
 [2, 'candle'],
 [1, 'blown'],
 [13, 'out,'],
 [1, 'thing.'],
 [5, 'After'],
 [4, 'while,'],
 [38, 'more'],
 [2, 'happened,'],
 [3, 'decided'],
 [1, 'once;'],
 [1, 'alas'],
 [3, 'Alice!'],
 [7, 'table'],
 [3, 'possibly'],
 [4, 'reach'],
 [9, 'it:'],
 [1, 'plainly'],
 [2, 'glass,'],
 [7, 'best'],
 [1, 'climb'],
 [3, 'legs'],
 [1, 'slippery;'],
 [1, 'trying,'],
 [35, 'thing'],
 [17, 'sat'],
 [2, 'cried.'],
 [9, '“Come,'],
 [15, 'there’s'],
 [2, 'crying'],
 [7, 'that!”'],
 [1, 'sharply;'],
 [1, 'advise'],
 [7, 'leave'],
 [1, 'minute!”'],
 [5, 'generally'],
 [15, 'gave'],
 [1, 'advice,'],
 [1, '(though'],
 [1, 'seldom'],
 [8, 'followed'],
 [2, 'it),'],
 [4, 'sometimes'],
 [1, 'scolded'],
 [3, 'severely'],
 [2, 'bring'],
 [4, 'tears'],
 [1, 'eyes;'],
 [5, 'remembered'],
 [3, 'box'],
 [1, 'cheated'],
 [6, 'game'],
 [3, 'croquet'],
 [2, 'playing'],
 [9, 'against'],
 [3, 'child'],
 [3, 'fond'],
 [1, 'pretending'],
 [20, 'two'],
 [1, 'people.'],
 [19, '“But'],
 [4, 'now,”'],
 [4, '“to'],
 [1, 'pretend'],
 [1, 'people!'],
 [11, 'hardly'],
 [10, 'enough'],
 [13, 'left'],
 [2, '_one_'],
 [1, 'respectable'],
 [1, 'person!”'],
 [1, 'Soon'],
 [4, 'eye'],
 [4, 'glass'],
 [8, 'lying'],
 [1, 'table:'],
 [2, 'cake,'],
 [1, '“EAT'],
 [1, 'ME”'],
 [1, 'currants.'],
 [20, '“Well,'],
 [18, 'it,”'],
 [11, 'makes'],
 [13, 'grow'],
 [3, 'larger,'],
 [27, 'can'],
 [1, 'key;'],
 [3, 'smaller,'],
 [1, 'creep'],
 [1, 'door;'],
 [5, 'garden,'],
 [48, 'don’t'],
 [4, 'care'],
 [1, 'happens!”'],
 [1, 'ate'],
 [2, 'bit,'],
 [13, 'anxiously'],
 [3, '“Which'],
 [1, 'way?'],
 [3, 'Which'],
 [1, 'way?”,'],
 [2, 'holding'],
 [4, 'growing,'],
 [6, 'surprised'],
 [3, 'remained'],
 [21, 'same'],
 [3, 'size:'],
 [2, 'sure,'],
 [2, 'happens'],
 [1, 'eats'],
 [3, 'expecting'],
 [1, 'happen,'],
 [2, 'dull'],
 [1, 'stupid'],
 [2, 'life'],
 [1, 'common'],
 [3, 'way.'],
 [14, 'set'],
 [1, 'work,'],
 [1, 'cake.'],
 [1, 'II.'],
 [1, 'Pool'],
 [1, 'Tears'],
 [1, '“Curiouser'],
 [1, 'curiouser!”'],
 [18, 'cried'],
 [1, 'surprised,'],
 [2, 'forgot'],
 [8, 'speak'],
 [1, 'English);'],
 [1, '“now'],
 [3, 'opening'],
 [1, 'largest'],
 [1, 'telescope'],
 [1, 'was!'],
 [1, 'Good-bye,'],
 [1, 'feet!”'],
 [1, '(for'],
 [9, 'far'],
 [1, 'off).'],
 [19, '“Oh,'],
 [5, 'shoes'],
 [1, 'stockings'],
 [6, 'now,'],
 [1, 'dears?'],
 [16, 'sure'],
 [13, '_I_'],
 [4, 'shan’t'],
 [1, 'able!'],
 [11, 'deal'],
 [2, 'myself'],
 [1, 'you:'],
 [1, 'can;—but'],
 [6, 'kind'],
 [3, 'them,”'],
 [5, '“or'],
 [21, 'won’t'],
 [9, 'want'],
 [1, 'go!'],
 [9, 'give'],
 [4, 'new'],
 [5, 'pair'],
 [3, 'boots'],
 [1, 'Christmas.”'],
 [1, 'planning'],
 [9, '“They'],
 [1, 'carrier,”'],
 [1, 'thought;'],
 [1, 'seem,'],
 [2, 'sending'],
 [2, 'presents'],
 [1, 'one’s'],
 [1, 'feet!'],
 [1, 'odd'],
 [1, 'directions'],
 [1, 'look!'],
 [1, '_Alice’s'],
 [1, 'Right'],
 [1, 'Foot,'],
 [1, 'Esq.,'],
 [1, 'Hearthrug,'],
 [1, 'Fender,_'],
 [1, '(_with'],
 [1, 'love_).'],
 [6, 'dear,'],
 [1, 'nonsense'],
 [1, 'talking!”'],
 [5, 'Just'],
 [2, 'struck'],
 [5, 'roof'],
 [1, 'hall:'],
 [2, 'fact'],
 [4, 'nine'],
 [2, 'door.'],
 [1, 'Poor'],
 [3, 'side,'],
 [2, 'eye;'],
 [1, 'hopeless'],
 [1, 'ever:'],
 [3, 'cry'],
 [32, '“You'],
 [2, 'ashamed'],
 [1, 'yourself,”'],
 [2, '“a'],
 [6, 'you,”'],
 [1, 'this),'],
 [1, 'way!'],
 [1, 'Stop'],
 [5, 'moment,'],
 [3, 'you!”'],
 [2, 'same,'],
 [1, 'shedding'],
 [1, 'gallons'],
 [3, 'tears,'],
 [4, 'until'],
 [6, 'pool'],
 [1, 'reaching'],
 [1, 'hall.'],
 [29, 'heard'],
 [3, 'pattering'],
 [4, 'distance,'],
 [7, 'hastily'],
 [1, 'dried'],
 [2, 'coming.'],
 [1, 'returning,'],
 [1, 'splendidly'],
 [1, 'dressed,'],
 [6, 'white'],
 [5, 'kid'],
 [5, 'gloves'],
 [8, 'fan'],
 [3, 'other:'],
 [94, 'he'],
 [2, 'trotting'],
 [1, 'hurry,'],
 [3, 'muttering'],
 [4, 'himself'],
 [2, 'came,'],
 [2, '“Oh!'],
 [8, 'Duchess,'],
 [3, 'Duchess!'],
 [1, 'Oh!'],
 [3, 'savage'],
 [13, 'kept'],
 [1, 'waiting!”'],
 [1, 'desperate'],
 [7, 'ready'],
 [9, 'help'],
 [2, 'one;'],
 [7, 'so,'],
 [6, 'began,'],
 [6, 'low,'],
 [3, 'timid'],
 [15, 'voice,'],
 [14, '“If'],
 [3, 'please,'],
 [1, 'sir—”'],
 [2, 'violently,'],
 [4, 'dropped'],
 [1, 'fan,'],
 [1, 'skurried'],
 [1, 'darkness'],
 [8, 'hard'],
 [1, 'go.'],
 [3, 'gloves,'],
 [19, 'and,'],
 [1, 'hall'],
 [1, 'hot,'],
 [1, 'fanning'],
 [1, 'talking:'],
 [1, '“Dear,'],
 [9, 'queer'],
 [9, 'everything'],
 [1, 'to-day!'],
 [2, 'yesterday'],
 [2, 'usual.'],
 [7, 'changed'],
 [1, 'night?'],
 [1, 'think:'],
 [1, 'morning?'],
 [6, 'feeling'],
 [1, 'different.'],
 [20, 'next'],
 [7, 'question'],
 [6, 'Who'],
 [13, 'am'],
 [1, 'I?'],
 [1, 'Ah,'],
 [3, '_that’s_'],
 [1, 'puzzle!”'],
 [10, 'thinking'],
 [2, 'age'],
 [19, '“I’m'],
 [1, 'Ada,”'],
 [5, 'hair'],
 [7, 'goes'],
 [1, 'ringlets,'],
 [3, 'mine'],
 [16, 'doesn’t'],
 [1, 'ringlets'],
 [2, 'all;'],
 [27, 'can’t'],
 [2, 'Mabel,'],
 [45, 'know'],
 [3, 'sorts'],
 [4, 'she,'],
 ...]

Analysis

  • It was easier for me to populate the dictionary than the 2D list
  • The dictionary build code ran faster than the 2D list
  • Dictionary - fast to look up a word, List - slow, requires loop
In [6]:
print( word_frequencies_dict["Alice"] )
221
In [7]:
for wordfreq in word_frequencies_2dlist:
    if "Alice" == wordfreq[1]:
        print(wordfreq[0])
221
  • Display sorted by frequency: dictonaries aren't ordered (would have to convert to a list), but I could sort the 2D list
In [8]:
word_frequencies_2dlist.sort(reverse=True)
word_frequencies_2dlist
Out[8]:
[[1513, 'the'],
 [715, 'and'],
 [706, 'to'],
 [608, 'a'],
 [492, 'of'],
 [485, 'she'],
 [416, 'said'],
 [347, 'it'],
 [344, 'in'],
 [327, 'was'],
 [251, 'you'],
 [249, 'I'],
 [237, 'as'],
 [221, 'Alice'],
 [213, 'that'],
 [204, 'her'],
 [196, 'at'],
 [176, 'had'],
 [168, 'with'],
 [151, 'all'],
 [138, 'on'],
 [137, 'be'],
 [125, 'very'],
 [125, 'for'],
 [119, '“I'],
 [118, 'little'],
 [108, 'they'],
 [103, 'so'],
 [103, 'not'],
 [101, 'but'],
 [97, 'out'],
 [94, 'he'],
 [93, 'his'],
 [89, 'The'],
 [86, 'this'],
 [85, 'what'],
 [84, 'about'],
 [82, 'were'],
 [81, 'up'],
 [79, 'went'],
 [77, 'one'],
 [77, 'down'],
 [76, 'Alice,'],
 [74, 'like'],
 [73, 'have'],
 [69, 'if'],
 [68, 'would'],
 [68, 'or'],
 [67, 'into'],
 [66, 'when'],
 [64, 'no'],
 [63, 'thought'],
 [63, 'is'],
 [63, 'could'],
 [60, '*'],
 [57, 'its'],
 [56, 'Mock'],
 [55, 'my'],
 [54, 'Alice.'],
 [53, 'your'],
 [53, 'quite'],
 [53, 'by'],
 [52, 'an'],
 [50, 'then'],
 [50, 'their'],
 [50, 'did'],
 [49, 'them'],
 [49, 'And'],
 [48, 'who'],
 [48, 'don’t'],
 [47, 'some'],
 [47, 'see'],
 [46, 'time'],
 [46, 'me'],
 [46, 'do'],
 [46, 'began'],
 [45, 'looked'],
 [45, 'know'],
 [45, 'got'],
 [44, 'there'],
 [43, 'only'],
 [43, 'just'],
 [43, 'get'],
 [40, 'such'],
 [40, 'much'],
 [40, 'herself'],
 [39, 'must'],
 [39, 'great'],
 [38, '“and'],
 [38, 'off'],
 [38, 'more'],
 [38, 'it,'],
 [38, 'go'],
 [38, 'came'],
 [37, 'which'],
 [37, 'way'],
 [37, 'never'],
 [37, 'how'],
 [37, 'are'],
 [36, 'think'],
 [36, 'been'],
 [36, 'any'],
 [35, 'thing'],
 [35, 'say'],
 [35, 'after'],
 [35, 'I’m'],
 [34, 'Queen'],
 [33, '“What'],
 [33, 'Turtle'],
 [33, 'She'],
 [32, '“You'],
 [32, 'large'],
 [32, 'from'],
 [31, 'put'],
 [31, 'over'],
 [31, 'herself,'],
 [31, 'again,'],
 [31, 'March'],
 [30, 'round'],
 [30, 'looking'],
 [29, 'made'],
 [29, 'long'],
 [29, 'heard'],
 [29, 'head'],
 [29, 'back'],
 [29, 'Rabbit'],
 [28, 'found'],
 [28, 'first'],
 [27, 'well'],
 [27, 'should'],
 [27, 'seemed'],
 [27, 'on,'],
 [27, 'might'],
 [27, 'can’t'],
 [27, 'can'],
 [27, 'King'],
 [26, 'upon'],
 [26, 'tell'],
 [26, 'said,'],
 [26, 'other'],
 [26, 'make'],
 [26, 'going'],
 [25, 'you,'],
 [25, 'rather'],
 [25, 'poor'],
 [25, 'look'],
 [25, 'last'],
 [25, 'it’s'],
 [24, '“It'],
 [24, 'without'],
 [24, 'Hatter'],
 [23, 'will'],
 [23, 'took'],
 [23, 'three'],
 [23, 'than'],
 [23, 'soon'],
 [23, 'now'],
 [23, 'him'],
 [23, 'good'],
 [23, 'felt'],
 [23, 'So'],
 [23, 'I’ll'],
 [23, 'Dormouse'],
 [22, 'nothing'],
 [22, 'come'],
 [22, 'White'],
 [22, 'Gryphon'],
 [21, 'won’t'],
 [21, 'wish'],
 [21, 'too'],
 [21, 'them,'],
 [21, 'shall'],
 [21, 'same'],
 [21, 'moment'],
 [21, 'half'],
 [21, 'getting'],
 [21, 'another'],
 [20, '“Well,'],
 [20, 'two'],
 [20, 'right'],
 [20, 'next'],
 [20, 'find'],
 [20, 'added'],
 [20, 'I’ve'],
 [19, '“but'],
 [19, '“Oh,'],
 [19, '“I’m'],
 [19, '“But'],
 [19, 'till'],
 [19, 'things'],
 [19, 'being'],
 [19, 'before'],
 [19, 'and,'],
 [19, 'There'],
 [18, 'voice'],
 [18, 'tried'],
 [18, 'take'],
 [18, 'once'],
 [18, 'it,”'],
 [18, 'her,'],
 [18, 'eyes'],
 [18, 'cried'],
 [17, '“And'],
 [17, 'this,'],
 [17, 'sort'],
 [17, 'sat'],
 [17, 'even'],
 [17, 'Queen,'],
 [17, 'Mouse'],
 [16, '“How'],
 [16, 'use'],
 [16, 'under'],
 [16, 'turned'],
 [16, 'tone,'],
 [16, 'sure'],
 [16, 'is,'],
 [16, 'ever'],
 [16, 'eat'],
 [16, 'doesn’t'],
 [16, 'curious'],
 [16, 'again.'],
 [16, 'Hare'],
 [16, 'Alice;'],
 [15, '“The'],
 [15, '“It’s'],
 [15, 'you’re'],
 [15, 'wonder'],
 [15, 'while'],
 [15, 'we'],
 [15, 'voice,'],
 [15, 'there’s'],
 [15, 'minute'],
 [15, 'it.'],
 [15, 'gave'],
 [15, 'door'],
 [15, 'called'],
 [15, 'away'],
 [15, 'This'],
 [15, 'King,'],
 [15, 'It'],
 [15, 'Gryphon.'],
 [15, 'Duchess'],
 [15, 'But'],
 [14, '“That’s'],
 [14, '“If'],
 [14, 'words'],
 [14, 'was,'],
 [14, 'something'],
 [14, 'set'],
 [14, 'replied'],
 [14, 'off,'],
 [14, 'near'],
 [14, 'idea'],
 [14, 'here'],
 [14, 'hear'],
 [14, 'both'],
 [14, 'anything'],
 [14, 'He'],
 [14, 'Gryphon,'],
 [13, '“I’ve'],
 [13, 'whole'],
 [13, 'that’s'],
 [13, 'saw'],
 [13, 'ran'],
 [13, 'out,'],
 [13, 'ought'],
 [13, 'old'],
 [13, 'left'],
 [13, 'knew'],
 [13, 'kept'],
 [13, 'her.'],
 [13, 'grow'],
 [13, 'anxiously'],
 [13, 'am'],
 [13, 'again'],
 [13, '_very_'],
 [13, '_I_'],
 [13, 'However,'],
 [13, 'Hatter.'],
 [12, 'wouldn’t'],
 [12, 'used'],
 [12, 'turning'],
 [12, 'try'],
 [12, 'through'],
 [12, 'talking'],
 [12, 'still'],
 [12, 'side'],
 [12, 'seen'],
 [12, 'remember'],
 [12, 'perhaps'],
 [12, 'many'],
 [12, 'every'],
 [12, 'end'],
 [12, 'down,'],
 [12, 'close'],
 [12, 'behind'],
 [12, 'among'],
 [12, 'King.'],
 [12, 'Caterpillar.'],
 [12, 'CHAPTER'],
 [12, 'As'],
 [11, '“Then'],
 [11, '“Of'],
 [11, 'whether'],
 [11, 'wasn’t'],
 [11, 'trying'],
 [11, 'these'],
 [11, 'see,'],
 [11, 'saying'],
 [11, 'may'],
 [11, 'makes'],
 [11, 'it?”'],
 [11, 'hurried'],
 [11, 'hardly'],
 [11, 'hand'],
 [11, 'glad'],
 [11, 'feet'],
 [11, 'didn’t'],
 [11, 'deal'],
 [11, 'day'],
 [11, 'course'],
 [11, 'better'],
 [11, 'beginning'],
 [11, 'before,'],
 [11, 'because'],
 [11, 'always'],
 [11, 'Queen.'],
 [11, 'Hare.'],
 [11, 'Caterpillar'],
 [10, 'walked'],
 [10, 'voice.'],
 [10, 'thinking'],
 [10, 'talk'],
 [10, 'sitting'],
 [10, 'people'],
 [10, 'nearly'],
 [10, 'having'],
 [10, 'enough'],
 [10, 'done'],
 [10, 'Hatter,'],
 [10, 'For'],
 [9, '“They'],
 [9, '“Not'],
 [9, '“No,'],
 [9, '“Come,'],
 [9, '“A'],
 [9, 'want'],
 [9, 'waited'],
 [9, 'us'],
 [9, 'up,'],
 [9, 'two,'],
 [9, 'tone.'],
 [9, 'those'],
 [9, 'they’re'],
 [9, 'that,”'],
 [9, 'suddenly'],
 [9, 'shouted'],
 [9, 'shook'],
 [9, 'rest'],
 [9, 'really'],
 [9, 'read'],
 [9, 'queer'],
 [9, 'own'],
 [9, 'opened'],
 [9, 'not,'],
 [9, 'know.”'],
 [9, 'jury'],
 [9, 'join'],
 [9, 'it;'],
 [9, 'it:'],
 [9, 'it.”'],
 [9, 'house,'],
 [9, 'help'],
 [9, 'gone'],
 [9, 'give'],
 [9, 'few'],
 [9, 'far'],
 [9, 'everything'],
 [9, 'door,'],
 [9, 'dear!'],
 [9, 'couldn’t'],
 [9, 'change'],
 [9, 'cats'],
 [9, 'against'],
 [9, 'afraid'],
 [9, 'Turtle.'],
 [9, 'They'],
 [9, 'Then'],
 [9, 'How'],
 [9, 'Dodo'],
 [9, 'Alice’s'],
 [9, '(she'],
 [8, '“you'],
 [8, '“it’s'],
 [8, '“Yes,'],
 [8, '“Why,'],
 [8, '“We'],
 [8, '“Off'],
 [8, '“Do'],
 [8, 'you’d'],
 [8, 'top'],
 [8, 'tone'],
 [8, 'suppose'],
 [8, 'speak'],
 [8, 'soldiers'],
 [8, 'small'],
 [8, 'running'],
 [8, 'room'],
 [8, 'repeated'],
 [8, 'reason'],
 [8, 'please'],
 [8, 'play'],
 [8, 'opportunity'],
 [8, 'on.'],
 [8, 'name'],
 [8, 'most'],
 [8, 'matter'],
 [8, 'making'],
 [8, 'lying'],
 [8, 'know.'],
 [8, 'know,”'],
 [8, 'keep'],
 [8, 'itself'],
 [8, 'house'],
 [8, 'herself.'],
 [8, 'hard'],
 [8, 'followed'],
 [8, 'feel'],
 [8, 'fan'],
 [8, 'explain'],
 [8, 'else'],
 [8, 'do,'],
 [8, 'cook'],
 [8, 'certainly'],
 [8, 'bit'],
 [8, 'believe'],
 [8, 'beautiful'],
 [8, 'asked.'],
 [8, 'asked'],
 [8, '_is_'],
 [8, 'Turtle,'],
 [8, 'Rabbit,'],
 [8, 'Mouse,'],
 [8, 'Duchess,'],
 [8, 'Cat'],
 [8, 'At'],
 [7, '“that'],
 [7, '“if'],
 [7, '“Why'],
 [7, '“There’s'],
 [7, 'you?”'],
 [7, 'work'],
 [7, 'word'],
 [7, 'wondering'],
 [7, 'why'],
 [7, 'where'],
 [7, 'way,'],
 [7, 'waiting'],
 [7, 'tired'],
 [7, 'that!”'],
 [7, 'table'],
 [7, 'stood'],
 [7, 'so,'],
 [7, 'seem'],
 [7, 'round,'],
 [7, 'ready'],
 [7, 'question'],
 [7, 'party'],
 [7, 'our'],
 [7, 'one,'],
 [7, 'offended'],
 [7, 'noticed'],
 [7, 'mouth'],
 [7, 'minutes'],
 [7, 'meaning'],
 [7, 'mean'],
 [7, 'low'],
 [7, 'live'],
 [7, 'let'],
 [7, 'leave'],
 [7, 'least'],
 [7, 'know,'],
 [7, 'it!”'],
 [7, 'heads'],
 [7, 'head!”'],
 [7, 'haven’t'],
 [7, 'hastily'],
 [7, 'hadn’t'],
 [7, 'grown'],
 [7, 'golden'],
 [7, 'goes'],
 [7, 'frightened'],
 [7, 'first,'],
 [7, 'finished'],
 [7, 'face'],
 [7, 'each'],
 [7, 'dry'],
 [7, 'could,'],
 [7, 'continued'],
 [7, 'changed'],
 [7, 'cat'],
 [7, 'bright'],
 [7, 'bottle'],
 [7, 'birds'],
 [7, 'best'],
 [7, 'begin'],
 [7, 'beg'],
 [7, 'ask'],
 [7, 'arm'],
 [7, 'again!”'],
 [7, '_your_'],
 [7, 'Why,'],
 [7, 'When'],
 [7, 'Queen’s'],
 [7, 'Majesty,”'],
 [7, 'Knave'],
 [7, 'I’d'],
 [7, 'Cat,'],
 [7, 'Alice:'],
 [6, '“for'],
 [6, '“You’re'],
 [6, '“Who'],
 [6, '“There'],
 [6, '“That'],
 [6, '“Come'],
 [6, '‘I'],
 [6, 'you,”'],
 [6, 'yet'],
 [6, 'written'],
 [6, 'world'],
 [6, 'white'],
 [6, 'watch'],
 [6, 'turn'],
 [6, 'trembling'],
 [6, 'told'],
 [6, 'times'],
 [6, 'time,'],
 [6, 'thought,'],
 [6, 'though'],
 [6, 'thing!”'],
 [6, 'then,”'],
 [6, 'then,'],
 [6, 'that?”'],
 [6, 'surprised'],
 [6, 'spoke.'],
 [6, 'slowly'],
 [6, 'size'],
 [6, 'sharp'],
 [6, 'repeat'],
 [6, 'pool'],
 [6, 'place'],
 [6, 'open'],
 [6, 'on!”'],
 [6, 'now,'],
 [6, 'not,”'],
 [6, 'neck'],
 [6, 'moral'],
 [6, 'melancholy'],
 [6, 'manage'],
 [6, 'low,'],
 [6, 'kind'],
 [6, 'it’ll'],
 [6, 'isn’t'],
 [6, 'indeed!”'],
 [6, 'inches'],
 [6, 'however,'],
 [6, 'hold'],
 [6, 'here,'],
 [6, 'has'],
 [6, 'hands'],
 [6, 'hand,'],
 [6, 'growing'],
 [6, 'game'],
 [6, 'full'],
 [6, 'four'],
 [6, 'forgotten'],
 [6, 'fell'],
 [6, 'feet,'],
 [6, 'feeling'],
 [6, 'fall'],
 [6, 'dreadfully'],
 [6, 'dear,'],
 [6, 'dear'],
 [6, 'creatures'],
 [6, 'but,'],
 [6, 'begun'],
 [6, 'began,'],
 [6, 'baby'],
 [6, 'answer'],
 [6, 'almost'],
 [6, 'about,'],
 [6, '_you_'],
 [6, '_that_'],
 [6, 'You'],
 [6, 'Who'],
 [6, 'Let'],
 [6, 'It’s'],
 [6, 'Hatter:'],
 [6, 'Dormouse,'],
 [6, 'Cheshire'],
 [6, 'A'],
 [5, '“the'],
 [5, '“or'],
 [5, '“it'],
 [5, '“Would'],
 [5, '“I’ll'],
 [5, '“In'],
 [5, '“He'],
 [5, 'you’ve'],
 [5, 'yourself'],
 [5, 'young'],
 [5, 'write'],
 [5, 'window,'],
 [5, 'waving'],
 [5, 'walking'],
 [5, 'understand'],
 [5, 'trees'],
 [5, 'tone:'],
 [5, 'time,”'],
 [5, 'them!”'],
 [5, 'that,'],
 [5, 'ten'],
 [5, 'tea'],
 [5, 'taking'],
 [5, 'table,'],
 [5, 'swam'],
 [5, 'sudden'],
 [5, 'spoke,'],
 [5, 'sounded'],
 [5, 'so,”'],
 [5, 'sit'],
 [5, 'sister'],
 [5, 'simple'],
 [5, 'silence.'],
 [5, 'sighed'],
 [5, 'shouldn’t'],
 [5, 'shoes'],
 [5, 'sentence'],
 [5, 'say,'],
 [5, 'roof'],
 [5, 'replied.'],
 [5, 'replied,'],
 [5, 'remembered'],
 [5, 'remarked.'],
 [5, 'puzzled'],
 [5, 'puppy'],
 [5, 'pleased'],
 [5, 'piece'],
 [5, 'pepper'],
 [5, 'pair'],
 [5, 'other,'],
 [5, 'once,'],
 [5, 'off.'],
 [5, 'notice'],
 [5, 'nice'],
 [5, 'much,”'],
 [5, 'moment,'],
 [5, 'me,”'],
 [5, 'marked'],
 [5, 'mad'],
 [5, 'last,'],
 [5, 'kid'],
 [5, 'key'],
 [5, 'jumped'],
 [5, 'interrupted'],
 [5, 'her:'],
 [5, 'hedgehog'],
 [5, 'head.'],
 [5, 'happen'],
 [5, 'hands,'],
 [5, 'hall,'],
 [5, 'hair'],
 [5, 'gloves'],
 [5, 'generally'],
 [5, 'garden,'],
 [5, 'foot'],
 [5, 'fetch'],
 [5, 'eyes,'],
 [5, 'exactly'],
 [5, 'everybody'],
 [5, 'either'],
 [5, 'drew'],
 [5, 'deep'],
 [5, 'dare'],
 [5, 'dance.'],
 [5, 'cut'],
 [5, 'crowded'],
 [5, 'court,'],
 [5, 'court'],
 [5, 'course,”'],
 [5, 'course,'],
 [5, 'conversation.'],
 [5, 'coming'],
 [5, 'children'],
 [5, 'call'],
 [5, 'broken'],
 [5, 'between'],
 [5, 'become'],
 [5, 'arms'],
 [5, 'arm,'],
 [5, 'along'],
 [5, 'air.'],
 [5, 'air,'],
 [5, 'across'],
 [5, '_would_'],
 [5, '_was_'],
 [5, '_not_'],
 [5, 'While'],
 [5, 'Pigeon'],
 [5, 'Oh'],
 [5, 'Just'],
 [5, 'In'],
 [5, 'Here'],
 [5, 'Hearts,'],
 [5, 'Do'],
 [5, 'Cat.'],
 [5, 'After'],
 [4, '“to'],
 [4, '“as'],
 [4, '“So'],
 [4, '“Now,'],
 [4, '“Now'],
 [4, '“I’d'],
 [4, '“Don’t'],
 [4, '“Call'],
 [4, '“Are'],
 [4, 'you’ll'],
 [4, 'yet,”'],
 [4, 'yer'],
 [4, 'writing'],
 [4, 'worth'],
 [4, 'witness'],
 [4, 'whispered'],
 [4, 'while,'],
 [4, 'wanted'],
 [4, 'walk'],
 [4, 'ventured'],
 [4, 'until'],
 [4, 'trouble'],
 [4, 'trial'],
 [4, 'tiny'],
 [4, 'timidly,'],
 [4, 'things!”'],
 [4, 'thing,'],
 [4, 'they’ll'],
 [4, 'tears'],
 [4, 'taught'],
 [4, 'taken'],
 [4, 'strange'],
 [4, 'stick,'],
 [4, 'stay'],
 [4, 'stand'],
 [4, 'spoke'],
 [4, 'song,'],
 [4, 'sometimes'],
 [4, 'somebody'],
 [4, 'sneezing'],
 [4, 'sleep'],
 [4, 'slates,'],
 [4, 'sir,'],
 [4, 'since'],
 [4, 'sight,'],
 [4, 'sides'],
 [4, 'shut'],
 [4, 'shrinking'],
 [4, 'short'],
 [4, 'she,'],
 [4, 'shan’t'],
 [4, 'several'],
 [4, 'seems'],
 [4, 'second'],
 [4, 'screamed'],
 [4, 'school'],
 [4, 'says'],
 [4, 'say,”'],
 [4, 'said.'],
 [4, 'remark,'],
 [4, 'reach'],
 [4, 'rate'],
 [4, 'quietly'],
 [4, 'question,'],
 [4, 'puzzling'],
 [4, 'pig,'],
 [4, 'pictures'],
 [4, 'perfectly'],
 [4, 'passed'],
 [4, 'pardon!”'],
 [4, 'pack'],
 [4, 'others'],
 [4, 'number'],
 [4, 'now.”'],
 [4, 'now,”'],
 [4, 'nine'],
 [4, 'new'],
 [4, 'nervous'],
 [4, 'nearer'],
 [4, 'mushroom'],
 [4, 'moved'],
 [4, 'more,'],
 [4, 'minute,'],
 [4, 'mind'],
 [4, 'meant'],
 [4, 'listen'],
 [4, 'likely'],
 [4, 'lessons'],
 [4, 'led'],
 [4, 'learn'],
 [4, 'lay'],
 [4, 'know—”'],
 [4, 'jury,'],
 [4, 'jumping'],
 [4, 'itself,'],
 [4, 'hurry'],
 [4, 'hot'],
 [4, 'hookah'],
 [4, 'history,'],
 [4, 'himself'],
 [4, 'him,'],
 [4, 'high'],
 [4, 'herself;'],
 [4, 'here?”'],
 [4, 'here,”'],
 [4, 'held'],
 [4, 'height'],
 [4, 'hastily.'],
 [4, 'hastily,'],
 [4, 'growing,'],
 [4, 'go,'],
 [4, 'glass'],
 [4, 'gardeners,'],
 [4, 'gardeners'],
 [4, 'garden'],
 [4, 'finish'],
 [4, 'fear'],
 [4, 'fast'],
 [4, 'fallen'],
 [4, 'fact,'],
 [4, 'face,'],
 [4, 'eye'],
 [4, 'exclaimed'],
 [4, 'except'],
 [4, 'ears'],
 [4, 'dropped'],
 [4, 'drink'],
 [4, 'draw'],
 [4, 'does'],
 [4, 'do,”'],
 [4, 'distance,'],
 [4, 'different'],
 [4, 'dead'],
 [4, 'day,'],
 [4, 'dance?'],
 [4, 'crowd'],
 [4, 'could.'],
 [4, 'conversation'],
 [4, 'chin'],
 [4, 'chance'],
 [4, 'case'],
 [4, 'carried'],
 [4, 'care'],
 [4, 'capital'],
 [4, 'busily'],
 [4, 'bottom'],
 [4, 'begins'],
 [4, 'beat'],
 [4, 'back,'],
 [4, 'asleep'],
 [4, 'argument'],
 [4, 'all.'],
 [4, 'again:'],
 [4, '_have_'],
 [4, '_can_'],
 [4, 'Will'],
 [4, 'What'],
 [4, 'Soup!'],
 [4, 'Soup'],
 [4, 'Soo—oop!'],
 [4, 'Said'],
 [4, 'On'],
 [4, 'No,'],
 [4, 'Lobster'],
 [4, 'Footman'],
 [4, 'First,'],
 [4, 'Father'],
 [4, 'Duchess;'],
 [4, 'Duchess:'],
 [4, 'Don’t'],
 [4, 'Dinah'],
 [4, 'Come'],
 [4, 'Beau—ootiful'],
 [4, 'An'],
 [4, '(it'],
 [4, '(Alice'],
 [3, '“we'],
 [3, '“so'],
 [3, '“in'],
 [3, '“because'],
 [3, '“Yes,”'],
 [3, '“Which'],
 [3, '“When'],
 [3, '“Very'],
 [3, '“Thank'],
 [3, '“Sure,'],
 [3, '“Please'],
 [3, '“Perhaps'],
 [3, '“Nothing'],
 [3, '“Let'],
 [3, '“Is'],
 [3, '“Hold'],
 [3, '“Have'],
 [3, '“Give'],
 [3, '“Did'],
 [3, '“As'],
 [3, '’em'],
 [3, 'youth,”'],
 [3, 'youth,'],
 [3, 'you!”'],
 [3, 'yet,'],
 [3, 'wrote'],
 [3, 'wood.'],
 [3, 'wonder?”'],
 [3, 'whiting'],
 [3, 'way.'],
 [3, 'watching'],
 [3, 'was,”'],
 [3, 'verses'],
 [3, 'verdict,”'],
 [3, 'venture'],
 [3, 'vanished'],
 [3, 'unfortunate'],
 [3, 'twinkling'],
 [3, 'twinkle,'],
 [3, 'twice,'],
 [3, 'tucked'],
 [3, 'trial’s'],
 [3, 'tree'],
 [3, 'tossing'],
 [3, 'to?”'],
 [3, 'to,'],
 [3, 'timid'],
 [3, 'throw'],
 [3, 'think—”'],
 [3, 'thing,”'],
 [3, 'they’d'],
 [3, 'them,”'],
 [3, 'that.”'],
 [3, 'tears,'],
 [3, 'teacup'],
 [3, 'tea,”'],
 [3, 'tarts,'],
 [3, 'tarts'],
 [3, 'tails'],
 [3, 'tail,'],
 [3, 'tail'],
 [3, 'table.'],
 [3, 'suppressed'],
 [3, 'suit'],
 [3, 'succeeded'],
 [3, 'stopped'],
 [3, 'stop'],
 [3, 'staring'],
 [3, 'spread'],
 [3, 'speaking,'],
 [3, 'sounds'],
 [3, 'sound'],
 [3, 'sorts'],
 [3, 'solemn'],
 [3, 'so.'],
 [3, 'smaller,'],
 [3, 'sleepy'],
 [3, 'size:'],
 [3, 'sing'],
 [3, 'silent'],
 [3, 'silence'],
 [3, 'side,'],
 [3, 'shrill'],
 [3, 'shriek'],
 [3, 'show'],
 [3, 'shoulder'],
 [3, 'she’s'],
 [3, 'shaking'],
 [3, 'severely'],
 [3, 'settled'],
 [3, 'see:'],
 [3, 'sea.'],
 [3, 'sea,'],
 [3, 'saying,'],
 [3, 'savage'],
 [3, 'said—”'],
 [3, 'said:'],
 [3, 'run'],
 [3, 'rules'],
 [3, 'round.'],
 [3, 'right,”'],
 [3, 'right,'],
 [3, 'reply.'],
 [3, 'replied;'],
 [3, 'repeating'],
 [3, 'remark.'],
 [3, 'remark'],
 ...]

Bottom line:

If my application mostly needs to look up word frequencies given a word, us a dictionary (convert to 2D list (or list of tuples) when necessary)

If my application needs to display the words in order a frequency more often, and individual word lookup is leess common, then use 2D list.