IGNITE-Pathways / hangman

Hangman
https://www.ignitepathways.org/post/hangman
1 stars 0 forks source link

Empty Word throws JSONDecodeError. #1

Closed guptaronav closed 3 years ago

guptaronav commented 3 years ago

`-------------------------------------------------------------------------- JSONDecodeError Traceback (most recent call last)

in 710 welcome() 711 elif state == 1: --> 712 enter_a_word() 713 elif state == 2: 714 play() in enter_a_word() 290 mouseRect = pygame.Rect(event.pos, (1,1)) 291 if mouseRect.colliderect(nextRect): --> 292 if is_word_valid(wordToGuess): 293 if len(wordToGuess)<3: 294 error_text="Must be above 3 characters." in is_word_valid(word) 384 response = requests.get("https://www.dictionaryapi.com/api/v3/references/collegiate/json/" + 385 word + "?key=1d70c06e-168f-438c-b958-43e3c8e4e081") --> 386 responseString = json.dumps(response.json()) 387 if "shortdef" in responseString: 388 return True`
guptaronav commented 3 years ago

try: responseString = json.dumps(response.json()) if "shortdef" in responseString: return True else: return False except: return False