python
import Levenshtein
def correct_spelling(word, dictionary):
min_distance = float('inf')
correction = None
for d in dictionary:
distance = Levenshtein.distance(word, d)
if distance < min_distance:
min_distance = distance
correction = d
return correction
word = "aple"
dictionary = ["apple", "banana", "orange"]
correction = correct_spelling(word, dictionary)
print(correction)
shell
pip install python-Levenshtein