From a2281d4aaecc1430a27d8f7abc3e2a7ae528e48d Mon Sep 17 00:00:00 2001 From: xero7689 Date: Mon, 11 Mar 2019 10:54:04 +0800 Subject: [PATCH] Fix index error while the result of meaning is not found While the input is meaningless, thesaurus.com will return a not found message. This will cause the part of using reg module to find meanings raising index error. I added a statement to determine this situation and directly return empty output. --- PyDictionary/core.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/PyDictionary/core.py b/PyDictionary/core.py index e63d8dc..da04bb0 100644 --- a/PyDictionary/core.py +++ b/PyDictionary/core.py @@ -124,6 +124,10 @@ def meaning(term, disable_errors=False): length = len(types) lists = html.findAll("ul") out = {} + + if 'Your search did not return any results.' in types[0]: + return out + for a in types: reg = str(lists[types.index(a)]) meanings = []