Instructions

The story is stored in the "story.txt" file. Open the file and read the contents into the story variable.

``````

In [62]:

# The story is stored in the file "story.txt".
f = open("story.txt", "r")
print(story)

``````
``````

There was once a great and noble frmer named Julius.  He was the best farmer in his village, and prabably even the whole world.  One day, he decidid to grw potatoes.

Julius knew that potatoes were hard to grow, so he kniw he hd to goe to the magic farmer in the sky to seek his guidance.  Julius set out on his journey aroudn noon one day.  It started raining almosty immediately.

Julius wondered if this was a sign that he shouldn't go on, but he perserved.  He became soaked, and stoped in the store to buy an umbrella.  He told the storekeeper, Reggie, about his journey.

Reggie told him that he was crzy to seek out the magic farmer; the last 10 people to try to find him had never come back.  Julius was undetered and decided to keep going.

He travelled many long days in alternatng searing heat and freezing cold.  At night, he curled into a ball and tried to sleep underneath trees along the roadside.

After mich anguish, Julius found the magic farmer, who gave him the secret of growing potatoes.

Julius came back to the village, and managed to grow the finest crop the village had ever seen.  Everyone had potatoes to eat for months, and sang Julius's praises.

``````

3: Tokenizing the file

Instructions

The story is loaded into the story variable.

Tokenize the story, and store the tokens into the tokenized_story variable.

``````

In [63]:

# We can split strings into lists with the .split() method.
# If we use a space as the input to .split(), it will split based on the space.
text = "Bears are probably better than sharks, but I can't get close enough to one to be sure."
tokenized_text = text.split(" ")
tokenized_story = story.split(" ")

print(tokenized_story)

``````
``````

['There', 'was', 'once', 'a', 'great', 'and', 'noble', 'frmer', 'named', 'Julius.', '', 'He', 'was', 'the', 'best', 'farmer', 'in', 'his', 'village,', 'and', 'prabably', 'even', 'the', 'whole', 'world.', '', 'One', 'day,', 'he', 'decidid', 'to', 'grw', 'potatoes.\n\n', 'Julius', 'knew', 'that', 'potatoes', 'were', 'hard', 'to', 'grow,', 'so', 'he', 'kniw', 'he', 'hd', 'to', 'goe', 'to', 'the', 'magic', 'farmer', 'in', 'the', 'sky', 'to', 'seek', 'his', 'guidance.', '', 'Julius', 'set', 'out', 'on', 'his', 'journey', 'aroudn', 'noon', 'one', 'day.', '', 'It', 'started', 'raining', 'almosty', 'immediately.\n\n', 'Julius', 'wondered', 'if', 'this', 'was', 'a', 'sign', 'that', 'he', "shouldn't", 'go', 'on,', 'but', 'he', 'perserved.', '', 'He', 'became', 'soaked,', 'and', 'stoped', 'in', 'the', 'store', 'to', 'buy', 'an', 'umbrella.', '', 'He', 'told', 'the', 'storekeeper,', 'Reggie,', 'about', 'his', 'journey.\n\n', 'Reggie', 'told', 'him', 'that', 'he', 'was', 'crzy', 'to', 'seek', 'out', 'the', 'magic', 'farmer;', 'the', 'last', '10', 'people', 'to', 'try', 'to', 'find', 'him', 'had', 'never', 'come', 'back.', '', 'Julius', 'was', 'undetered', 'and', 'decided', 'to', 'keep', 'going.\n\n', 'He', 'travelled', 'many', 'long', 'days', 'in', 'alternatng', 'searing', 'heat', 'and', 'freezing', 'cold.', '', 'At', 'night,', 'he', 'curled', 'into', 'a', 'ball', 'and', 'tried', 'to', 'sleep', 'underneath', 'trees', 'along', 'the', 'roadside.\n\n', 'After', 'mich', 'anguish,', 'Julius', 'found', 'the', 'magic', 'farmer,', 'who', 'gave', 'him', 'the', 'secret', 'of', 'growing', 'potatoes.\n\n', 'Julius', 'came', 'back', 'to', 'the', 'village,', 'and', 'managed', 'to', 'grow', 'the', 'finest', 'crop', 'the', 'village', 'had', 'ever', 'seen.', '', 'Everyone', 'had', 'potatoes', 'to', 'eat', 'for', 'months,', 'and', 'sang', "Julius's", 'praises.\n']

``````

4: Replacing punctuation

Instructions

The story has been loaded into tokenized_story.

Replace all of the punctuation in each of the tokens.

You'll need to loop through tokenized_story to do so.

You'll need to use multiple replace statements, one for each punctuation character to replace.

Append the token to no_punctuation_tokens once you are done replacing characters.

Don't forget to remove newlines!

Print out no_punctuation_tokens if you want to see which types of punctuation are still in the data.

``````

In [64]:

# We can use the .replace function to replace punctuation in a string.
text = "Who really shot John F. Kennedy?"
text = text.replace("?", "?!")

# The question mark has been replaced with ?!.
##print(text)

# We can replace strings with blank spaces, meaning that they are just removed.
text = text.replace("?", "")

# The question mark is gone now.
##print(text)

no_punctuation_tokens = []

for token in tokenized_story:
for p in [".", ",", "\n", "'", ";", "?", "!", "-", ":"]:
token = token.replace(p, "")
no_punctuation_tokens.append(token)
print(no_punctuation_tokens)

``````
``````

['There', 'was', 'once', 'a', 'great', 'and', 'noble', 'frmer', 'named', 'Julius', '', 'He', 'was', 'the', 'best', 'farmer', 'in', 'his', 'village', 'and', 'prabably', 'even', 'the', 'whole', 'world', '', 'One', 'day', 'he', 'decidid', 'to', 'grw', 'potatoes', 'Julius', 'knew', 'that', 'potatoes', 'were', 'hard', 'to', 'grow', 'so', 'he', 'kniw', 'he', 'hd', 'to', 'goe', 'to', 'the', 'magic', 'farmer', 'in', 'the', 'sky', 'to', 'seek', 'his', 'guidance', '', 'Julius', 'set', 'out', 'on', 'his', 'journey', 'aroudn', 'noon', 'one', 'day', '', 'It', 'started', 'raining', 'almosty', 'immediately', 'Julius', 'wondered', 'if', 'this', 'was', 'a', 'sign', 'that', 'he', 'shouldnt', 'go', 'on', 'but', 'he', 'perserved', '', 'He', 'became', 'soaked', 'and', 'stoped', 'in', 'the', 'store', 'to', 'buy', 'an', 'umbrella', '', 'He', 'told', 'the', 'storekeeper', 'Reggie', 'about', 'his', 'journey', 'Reggie', 'told', 'him', 'that', 'he', 'was', 'crzy', 'to', 'seek', 'out', 'the', 'magic', 'farmer', 'the', 'last', '10', 'people', 'to', 'try', 'to', 'find', 'him', 'had', 'never', 'come', 'back', '', 'Julius', 'was', 'undetered', 'and', 'decided', 'to', 'keep', 'going', 'He', 'travelled', 'many', 'long', 'days', 'in', 'alternatng', 'searing', 'heat', 'and', 'freezing', 'cold', '', 'At', 'night', 'he', 'curled', 'into', 'a', 'ball', 'and', 'tried', 'to', 'sleep', 'underneath', 'trees', 'along', 'the', 'roadside', 'After', 'mich', 'anguish', 'Julius', 'found', 'the', 'magic', 'farmer', 'who', 'gave', 'him', 'the', 'secret', 'of', 'growing', 'potatoes', 'Julius', 'came', 'back', 'to', 'the', 'village', 'and', 'managed', 'to', 'grow', 'the', 'finest', 'crop', 'the', 'village', 'had', 'ever', 'seen', '', 'Everyone', 'had', 'potatoes', 'to', 'eat', 'for', 'months', 'and', 'sang', 'Juliuss', 'praises']

``````

5: Lowercasing the words

Instructions

The tokens without punctuation have been loaded into no_punctuation_tokens.

Loop through the tokens and lowercase each one.

Append each token to lowercase_tokens when you're done lowercasing.

``````

In [65]:

# We can make strings all lowercase using the .lower() method.
text = "MY CAPS LOCK IS STUCK"
text = text.lower()

# The text is much nicer to read now.
print(text)

lowercase_tokens = []

for token in no_punctuation_tokens:
lowercase_tokens.append(token.lower())
print(lowercase_tokens)

``````
``````

my caps lock is stuck
['there', 'was', 'once', 'a', 'great', 'and', 'noble', 'frmer', 'named', 'julius', '', 'he', 'was', 'the', 'best', 'farmer', 'in', 'his', 'village', 'and', 'prabably', 'even', 'the', 'whole', 'world', '', 'one', 'day', 'he', 'decidid', 'to', 'grw', 'potatoes', 'julius', 'knew', 'that', 'potatoes', 'were', 'hard', 'to', 'grow', 'so', 'he', 'kniw', 'he', 'hd', 'to', 'goe', 'to', 'the', 'magic', 'farmer', 'in', 'the', 'sky', 'to', 'seek', 'his', 'guidance', '', 'julius', 'set', 'out', 'on', 'his', 'journey', 'aroudn', 'noon', 'one', 'day', '', 'it', 'started', 'raining', 'almosty', 'immediately', 'julius', 'wondered', 'if', 'this', 'was', 'a', 'sign', 'that', 'he', 'shouldnt', 'go', 'on', 'but', 'he', 'perserved', '', 'he', 'became', 'soaked', 'and', 'stoped', 'in', 'the', 'store', 'to', 'buy', 'an', 'umbrella', '', 'he', 'told', 'the', 'storekeeper', 'reggie', 'about', 'his', 'journey', 'reggie', 'told', 'him', 'that', 'he', 'was', 'crzy', 'to', 'seek', 'out', 'the', 'magic', 'farmer', 'the', 'last', '10', 'people', 'to', 'try', 'to', 'find', 'him', 'had', 'never', 'come', 'back', '', 'julius', 'was', 'undetered', 'and', 'decided', 'to', 'keep', 'going', 'he', 'travelled', 'many', 'long', 'days', 'in', 'alternatng', 'searing', 'heat', 'and', 'freezing', 'cold', '', 'at', 'night', 'he', 'curled', 'into', 'a', 'ball', 'and', 'tried', 'to', 'sleep', 'underneath', 'trees', 'along', 'the', 'roadside', 'after', 'mich', 'anguish', 'julius', 'found', 'the', 'magic', 'farmer', 'who', 'gave', 'him', 'the', 'secret', 'of', 'growing', 'potatoes', 'julius', 'came', 'back', 'to', 'the', 'village', 'and', 'managed', 'to', 'grow', 'the', 'finest', 'crop', 'the', 'village', 'had', 'ever', 'seen', '', 'everyone', 'had', 'potatoes', 'to', 'eat', 'for', 'months', 'and', 'sang', 'juliuss', 'praises']

``````

7: Making a basic function

Instructions

Define a function that takes degrees in fahrenheit as an input, and return degrees celsius

Use it to convert 100 degrees fahrenheit to celsius. Assign the result to celsius_100.

Use it to convert 150 degrees fahrenheit to celsius. Assign the result to celsius_150.

``````

In [66]:

# A simple function that takes in a number of miles, and turns it into kilometers
# The input at position 0 will be put into the miles variable.
def miles_to_km(miles):
# return is a special keyword that indicates that the function will output whatever comes after it.
return miles/0.62137

# Returns the number of kilometers equivalent to one mile
print(miles_to_km(1))

# Convert a from 10 miles to kilometers
a = 10
a = miles_to_km(a)

# We can convert and assign to a different variable
b = 50
c = miles_to_km(b)

fahrenheit = 80
celsius = (fahrenheit - 32)/1.8

def f2c(f):
c = (f - 32)/1.8
return c

celsius_100 = f2c(100)

celsius_150 = f2c(150)

print(celsius_100, celsius_150)

``````
``````

1.6093470878864444
37.77777777777778 65.55555555555556

``````

8: Practice: functions

Instructions

Make a function that takes a string as input and outputs a lowercase version.

Then use it to turn the string lowercase_me to lowercase.

Assign the result to lowercased_string.

``````

In [67]:

def split_string(text):
return text.split(" ")

sally = "Sally sells seashells by the seashore."
# This splits the string into a list.
print(split_string(sally))

# We can assign the output of a function to a variable.
sally_tokens = split_string(sally)

lowercase_me = "I wish I was in ALL lowercase"

def to_lowercase(text):
return text.lower()

lowercased_string = to_lowercase(lowercase_me)
print(lowercased_string)

``````
``````

['Sally', 'sells', 'seashells', 'by', 'the', 'seashore.']
i wish i was in all lowercase

``````

9: Types of errors

Instructions

There are multiple syntax errors in the code cell below. You can tell because of the error showing up in the results panel. Fix the errors and get the code running properly. It should print all of the items in a.

``````

In [68]:

# Sometimes, you will have problems with your code that cause python to throw an exception.
# Don't worry, it happens to all of us many times a day.
# An exception means that the program can't run, so you'll get an error in the results view instead of the normal output.
# There are a few different types of exceptions.
# The first we'll look at is a SyntaxError.
# This means that something is typed incorrectly (statements misspelled, quotes missing, and so on)

a = ["Errors are no fun!", "But they can be fixed", "Just fix the syntax and everything will be fine"]
b = 5

for item in a:
if b == 5:
print(item)

``````
``````

Errors are no fun!
But they can be fixed
Just fix the syntax and everything will be fine

``````

10: More syntax errors

Instructions

The code below has multiple syntax errors. Fix them so the code prints out "I never liked that 6"

``````

In [69]:

a = 5

if a == 6:
print("6 is obviously the best number")
print("What's going on, guys?")
else:
print("I never liked that 6")

``````
``````

I never liked that 6

``````

11: Index errors

Instructions

The code below has multiple index errors. Fix them so that the code prints the last item in each list.

``````

In [70]:

# An index error is when a nonexistent index in a list is accessed.
the_list = ["Harrison Ford", "Mark Hamill"]

print(the_list[-1])

another_list = ["Jabba"]

print(another_list[-1])

``````
``````

Mark Hamill
Jabba

``````

13: Multiline functions

Instructions

All the tokens from Julius's story are in the tokenized_story variable.

Write a function that removes all punctuation from an input string.

Then loop over tokenized_story and call the function to remove the punctuation from each token.

Append the tokens to no_punctuation_tokens.

``````

In [71]:

# Functions can have multiple lines in the function body.
def do_math(number):
# Multiply the number by 10
number = number * 10
# Add 20 to the number
number = number + 20
return number

print(do_math(20))
a = do_math(10)

no_punctuation_tokens = []

def remove_punctuation(text):
return text.replace("\n", "").replace(".", "").replace(",", "") \
.replace(":", "").replace(";", "") \
.replace("!", "").replace("?", "").replace("'", "")

for token in tokenized_story:
no_punctuation_tokens.append(remove_punctuation(token))
print(no_punctuation_tokens)

``````
``````

220
['There', 'was', 'once', 'a', 'great', 'and', 'noble', 'frmer', 'named', 'Julius', '', 'He', 'was', 'the', 'best', 'farmer', 'in', 'his', 'village', 'and', 'prabably', 'even', 'the', 'whole', 'world', '', 'One', 'day', 'he', 'decidid', 'to', 'grw', 'potatoes', 'Julius', 'knew', 'that', 'potatoes', 'were', 'hard', 'to', 'grow', 'so', 'he', 'kniw', 'he', 'hd', 'to', 'goe', 'to', 'the', 'magic', 'farmer', 'in', 'the', 'sky', 'to', 'seek', 'his', 'guidance', '', 'Julius', 'set', 'out', 'on', 'his', 'journey', 'aroudn', 'noon', 'one', 'day', '', 'It', 'started', 'raining', 'almosty', 'immediately', 'Julius', 'wondered', 'if', 'this', 'was', 'a', 'sign', 'that', 'he', 'shouldnt', 'go', 'on', 'but', 'he', 'perserved', '', 'He', 'became', 'soaked', 'and', 'stoped', 'in', 'the', 'store', 'to', 'buy', 'an', 'umbrella', '', 'He', 'told', 'the', 'storekeeper', 'Reggie', 'about', 'his', 'journey', 'Reggie', 'told', 'him', 'that', 'he', 'was', 'crzy', 'to', 'seek', 'out', 'the', 'magic', 'farmer', 'the', 'last', '10', 'people', 'to', 'try', 'to', 'find', 'him', 'had', 'never', 'come', 'back', '', 'Julius', 'was', 'undetered', 'and', 'decided', 'to', 'keep', 'going', 'He', 'travelled', 'many', 'long', 'days', 'in', 'alternatng', 'searing', 'heat', 'and', 'freezing', 'cold', '', 'At', 'night', 'he', 'curled', 'into', 'a', 'ball', 'and', 'tried', 'to', 'sleep', 'underneath', 'trees', 'along', 'the', 'roadside', 'After', 'mich', 'anguish', 'Julius', 'found', 'the', 'magic', 'farmer', 'who', 'gave', 'him', 'the', 'secret', 'of', 'growing', 'potatoes', 'Julius', 'came', 'back', 'to', 'the', 'village', 'and', 'managed', 'to', 'grow', 'the', 'finest', 'crop', 'the', 'village', 'had', 'ever', 'seen', '', 'Everyone', 'had', 'potatoes', 'to', 'eat', 'for', 'months', 'and', 'sang', 'Juliuss', 'praises']

``````

14: Making a function to lowercase input

Instructions

We've written the remove_punctuation function for you. Can you add to it so that it also makes the output lowercase?

Then loop over the tokens in tokenized_story and normalize them with the function.

Append the tokens to normalized_tokens when you're done.

``````

In [72]:

# This is our function to remove punctuation.
def remove_punctuation(token):
token = token.replace(".","")
token = token.replace(",","")
token = token.replace("'", "")
token = token.replace(";", "")
token = token.replace("\n", "")

# We've read the tokens from Julius's story into the tokenized_story variable.
# Can you add to the remove_punctuation function so it also lowercases the tokens?
# Then loop over the tokens in tokenized_story, normalize them with the function, and append them to normalized_tokens.
normalized_tokens = []

for token in tokenized_story:
normalized_tokens.append(remove_punctuation(token))

print(normalized_tokens)

``````
``````

['there', 'was', 'once', 'a', 'great', 'and', 'noble', 'frmer', 'named', 'julius', '', 'he', 'was', 'the', 'best', 'farmer', 'in', 'his', 'village', 'and', 'prabably', 'even', 'the', 'whole', 'world', '', 'one', 'day', 'he', 'decidid', 'to', 'grw', 'potatoes', 'julius', 'knew', 'that', 'potatoes', 'were', 'hard', 'to', 'grow', 'so', 'he', 'kniw', 'he', 'hd', 'to', 'goe', 'to', 'the', 'magic', 'farmer', 'in', 'the', 'sky', 'to', 'seek', 'his', 'guidance', '', 'julius', 'set', 'out', 'on', 'his', 'journey', 'aroudn', 'noon', 'one', 'day', '', 'it', 'started', 'raining', 'almosty', 'immediately', 'julius', 'wondered', 'if', 'this', 'was', 'a', 'sign', 'that', 'he', 'shouldnt', 'go', 'on', 'but', 'he', 'perserved', '', 'he', 'became', 'soaked', 'and', 'stoped', 'in', 'the', 'store', 'to', 'buy', 'an', 'umbrella', '', 'he', 'told', 'the', 'storekeeper', 'reggie', 'about', 'his', 'journey', 'reggie', 'told', 'him', 'that', 'he', 'was', 'crzy', 'to', 'seek', 'out', 'the', 'magic', 'farmer', 'the', 'last', '10', 'people', 'to', 'try', 'to', 'find', 'him', 'had', 'never', 'come', 'back', '', 'julius', 'was', 'undetered', 'and', 'decided', 'to', 'keep', 'going', 'he', 'travelled', 'many', 'long', 'days', 'in', 'alternatng', 'searing', 'heat', 'and', 'freezing', 'cold', '', 'at', 'night', 'he', 'curled', 'into', 'a', 'ball', 'and', 'tried', 'to', 'sleep', 'underneath', 'trees', 'along', 'the', 'roadside', 'after', 'mich', 'anguish', 'julius', 'found', 'the', 'magic', 'farmer', 'who', 'gave', 'him', 'the', 'secret', 'of', 'growing', 'potatoes', 'julius', 'came', 'back', 'to', 'the', 'village', 'and', 'managed', 'to', 'grow', 'the', 'finest', 'crop', 'the', 'village', 'had', 'ever', 'seen', '', 'everyone', 'had', 'potatoes', 'to', 'eat', 'for', 'months', 'and', 'sang', 'juliuss', 'praises']

``````

16: Practice with multiple argument functions

Instructions

Create a multiply function that takes in x, y, and z argument.

The function should return x y z

Assign the values of multiply(10,3,5) to a

Assign the values of multiply(20,-1,3) to b

``````

In [73]:

# This function takes two arguments, at positions 0 and 1
def divide(x,y):
return x/y

# 5 is assigned to x, and 1 is assigned to y based on positions
print(divide(5,1))

# 1 is assigned to x, and 5 is assigned to y based on positions.
print(divide(1,5))

``````
``````

5.0
0.2

``````
``````

In [74]:

def multiply(x,y,z):
return x*y*z

a,b = multiply(10,3,5), multiply(20,-1,3)

``````
``````

In [75]:

print(a,b)

``````
``````

150 -60

``````

17: Reading in and normalizing the dictionary

The dictionary is stored in dictionary.txt

We'll need to read it in and normalize it.

Instructions

Read in the dictionary from the "dictionary.txt" file.

Split it into tokens based on the space character.

Normalize each token using the normalize function.

Append the normalized tokens to normalized_dictionary_tokens

``````

In [76]:

def normalize(token):
token = token.replace(".","")
token = token.replace(",","")
token = token.replace("'", "")
token = token.replace(";", "")
token = token.replace("\n", "")
token = token.lower()

normalized_dictionary_tokens = []

``````

``````

In [77]:

f = open("dictionary.txt", "r")
print(text)

tokens = text.split(" ")
for token in tokens:
normalized_dictionary_tokens.append(normalize(token))

print(normalized_dictionary_tokens)

``````
``````

a about after almost along alternating an and anguish around at back ball became best but buy came cold come crop crazy curled day days decided decided eat even ever everyone farmer farmer find finest for found freezing farmer gave go going great grow growing guidance had hard he heat him his if immediately in into it journey julius juliuss keep knew last long magic managed many much months named never night noble noon of on once one out people persevered potatoes probably praises raining reggie roadside sang searing secret seek seen set shouldnt sign sky sleep so soaked started stopped store storekeeper that the there this to told travelled trees tried try umbrella underneath undeterred village was were who whole wondered world

['a', 'about', 'after', 'almost', 'along', 'alternating', 'an', 'and', 'anguish', 'around', 'at', 'back', 'ball', 'became', 'best', 'but', 'buy', 'came', 'cold', 'come', 'crop', 'crazy', 'curled', 'day', 'days', 'decided', 'decided', 'eat', 'even', 'ever', 'everyone', 'farmer', 'farmer', 'find', 'finest', 'for', 'found', 'freezing', 'farmer', 'gave', 'go', 'going', 'great', 'grow', 'growing', 'guidance', 'had', 'hard', 'he', 'heat', 'him', 'his', 'if', 'immediately', 'in', 'into', 'it', 'journey', 'julius', 'juliuss', 'keep', 'knew', 'last', 'long', 'magic', 'managed', 'many', 'much', 'months', 'named', 'never', 'night', 'noble', 'noon', 'of', 'on', 'once', 'one', 'out', 'people', 'persevered', 'potatoes', 'probably', 'praises', 'raining', 'reggie', 'roadside', 'sang', 'searing', 'secret', 'seek', 'seen', 'set', 'shouldnt', 'sign', 'sky', 'sleep', 'so', 'soaked', 'started', 'stopped', 'store', 'storekeeper', 'that', 'the', 'there', 'this', 'to', 'told', 'travelled', 'trees', 'tried', 'try', 'umbrella', 'underneath', 'undeterred', 'village', 'was', 'were', 'who', 'whole', 'wondered', 'world']

``````

18: Finding words that aren't spelled correctly

A solution is in sight! All we need to do is loop through the normalized story tokens, and check if they are in the dictionary. If they aren't, they are potential misspellings.

Instructions

The normalized story tokens are in normalized_story_tokens, and the normalized dictionary tokens are in normalized_dictionary_tokens.

Loop through the story tokens, and check if each token is in the dictionary.

If the token is in normalized_dictionary_tokens, append it to correctly_spelled

If it isn't, append it to potential_misspellings.

``````

In [78]:

potential_misspellings = []
correctly_spelled = []

``````

``````

In [79]:

normalized_story_tokens = normalized_tokens

``````
``````

In [80]:

for token in normalized_story_tokens:
if token in normalized_dictionary_tokens:
correctly_spelled.append(token)
else:
potential_misspellings.append(token)
print(potential_misspellings)
print(correctly_spelled)

``````
``````

['frmer', '', 'prabably', '', 'decidid', 'grw', 'kniw', 'hd', 'goe', '', 'aroudn', '', 'almosty', 'perserved', '', 'stoped', '', 'crzy', '10', '', 'undetered', 'alternatng', '', 'mich', '']
['there', 'was', 'once', 'a', 'great', 'and', 'noble', 'named', 'julius', 'he', 'was', 'the', 'best', 'farmer', 'in', 'his', 'village', 'and', 'even', 'the', 'whole', 'world', 'one', 'day', 'he', 'to', 'potatoes', 'julius', 'knew', 'that', 'potatoes', 'were', 'hard', 'to', 'grow', 'so', 'he', 'he', 'to', 'to', 'the', 'magic', 'farmer', 'in', 'the', 'sky', 'to', 'seek', 'his', 'guidance', 'julius', 'set', 'out', 'on', 'his', 'journey', 'noon', 'one', 'day', 'it', 'started', 'raining', 'immediately', 'julius', 'wondered', 'if', 'this', 'was', 'a', 'sign', 'that', 'he', 'shouldnt', 'go', 'on', 'but', 'he', 'he', 'became', 'soaked', 'and', 'in', 'the', 'store', 'to', 'buy', 'an', 'umbrella', 'he', 'told', 'the', 'storekeeper', 'reggie', 'about', 'his', 'journey', 'reggie', 'told', 'him', 'that', 'he', 'was', 'to', 'seek', 'out', 'the', 'magic', 'farmer', 'the', 'last', 'people', 'to', 'try', 'to', 'find', 'him', 'had', 'never', 'come', 'back', 'julius', 'was', 'and', 'decided', 'to', 'keep', 'going', 'he', 'travelled', 'many', 'long', 'days', 'in', 'searing', 'heat', 'and', 'freezing', 'cold', 'at', 'night', 'he', 'curled', 'into', 'a', 'ball', 'and', 'tried', 'to', 'sleep', 'underneath', 'trees', 'along', 'the', 'roadside', 'after', 'anguish', 'julius', 'found', 'the', 'magic', 'farmer', 'who', 'gave', 'him', 'the', 'secret', 'of', 'growing', 'potatoes', 'julius', 'came', 'back', 'to', 'the', 'village', 'and', 'managed', 'to', 'grow', 'the', 'finest', 'crop', 'the', 'village', 'had', 'ever', 'seen', 'everyone', 'had', 'potatoes', 'to', 'eat', 'for', 'months', 'and', 'sang', 'juliuss', 'praises']

``````
``````

In [ ]:

``````