The nearest word

Report a typo

You get a string of words in the input. Find a word with the minimum Levenshtein distance to the first word in the input string. If there are two or more words that comply to this condition, print out the first one.

Sample Input 1:

grewsome grisly frightful horrid ghastly awesome gruesome

Sample Output 1:

gruesome
Write a program in Python 3
import nltk
from nltk import word_tokenize
# you get a string of words in the input
# we tokenized these words for you

all_words = list(word_tokenize(str(input())))
word = all_words[0] # you have to compare this word with others
others = all_words[1:] # other words stored here
# code below
___

Create a free account to access the full topic