NOTES

Demo

Use example from this summer

Imports

Example

Do a basic demo to get students started on the Wikipedia mammal species list problem.

Highlight

Example

import re

def get_species(inputstring):
    species_re = "''\[\[(.*)\]\]''"
    species_search = re.search(species_re, inputstring)
    if species_search:
        return species_search.group(1)

inputfile = open('wikipedia_rodents.txt')
results = []
nomatch = []
for line in inputfile:
    species = get_species(line)
    if species:
        splitspecies = species.split()
        results.append(species)
    else:
        nomatch.append(line)