Dictionary in Python is an unordered collection of data values, used to store data values like a map, which unlike other Data Types that hold only single value as an element, Dictionary holds
key:value pair. Key value is provided in the dictionary to make it more optimized. Each key-value pair in a Dictionary is separated by a colon :, whereas each key is separated by a ‘comma’.
A Dictionary in Python works similar to the Dictionary in a real world. Keys of a Dictionary must be unique and of immutable data type such as Strings, Integers, and tuples, but the key-values can be repeated and be of any type.
Note – To know more about dictionary click here.
- json: It comes built-in with python, so there is no need to install it externally. To know more about JSON click here.
- difflib: This module provides classes and functions for comparing sequences. It also comes built-in with python so there is no need to install it externally.
- Download a
JSONfile containing English dictionary words in a python dictionaries data type format, or arrange the file content in that way.
- Create a folder and add the downloaded .json file and python script in that folder.
- In python editor, import the required modules.
Below is the implementation.
Important, the output should not vary with different cases such as upper case and lower case input of same text should be same i.e rain or Rain or RaIn should produce same output. Also if user mistakes with spelling of word it should return the close words related to the word input or print a user friendly message that word does not exist.
For mixed cases –
If spelling is wrong it gives the word holding closest meaning with word typed by the user as shown. Suppose if the input is “rane” and the user wanter to search “range”, then the output will be as follows.
- OCR of English alphabets in Python OpenCV
- Python - Append Dictionary Keys and Values ( In order ) in dictionary
- Python | Convert flattened dictionary into nested dictionary
- Python | Convert nested dictionary into flattened dictionary
- Python - Filter dictionary values in heterogenous dictionary
- Python - English (Latin) to Hindi (Devanagiri) text convertor GUI using Tkinter
- Regular Dictionary vs Ordered Dictionary in Python
- Python | Dictionary initialization with common dictionary
- Python | Pretty Print a dictionary with dictionary value
- Python | Convert string dictionary to dictionary
- Python - Replace dictionary value from other dictionary
- Python - Update dictionary with other dictionary
- divmod() in Python and its application
- isprintable() in Python and its application
- Python - Convert Dictionary Value list to Dictionary List
- GUI chat application using Tkinter in Python
- Create First GUI Application using Python-Tkinter
- Hierarchical treeview in Python GUI application
- Birthday Reminder Application in Python
- Python | ToDo GUI Application using Tkinter
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.