Open In App

enchant.dict_exists() in Python

Improve
Improve
Like Article
Like
Save
Share
Report

Enchant is a module in python which is used to check the spelling of a word, gives suggestions to correct words. Also, gives antonym and synonym of words. It checks whether a word exists in dictionary or not.

enchant.dict_exists()

enchant.dict_exists() is an inbuilt method of enchant module. It is used to check the availability of a dictionary of a particular language.

Syntax : enchant.dict_exists(tag)

Parameter :
tag : the code of the language dictionary in string datatype

Returns : a boolean value, True if the dictionary exists, False if it does not exists

Example 1: When enchant.dict_exists() returns True.




# import the enchant module
import enchant
  
# American English dictionary
tag = "en_US"
  
# check whether American English(en_US) 
# dictionary exists or not
exists = enchant.dict_exists(tag)
if exists == True:
    print("The dictionary for " + tag + " exists.")
else:
    print("The dictionary for " + tag + " does not exists.")


Output :

The dictionary for en_US exists.

Example 2: When enchant.dict_exists() returns False.




# import the enchant module
import enchant
  
# Hindi dictionary
tag = "hi_IN"
  
# check whether Hindi(hi_IN) 
# dictionary exists or not
exists = enchant.dict_exists(tag)
if exists == True:
    print("The dictionary for " + tag + " exists.")
else:
    print("The dictionary for " + tag + " does not exists.")


Output :

The dictionary for hi_IN does not exists.


Last Updated : 26 May, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads