Skip to content

Commit 94fee6a

Browse files
Feature complete: Dictionary check of attempt
1 parent 8e7c091 commit 94fee6a

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

__pycache__/game.cpython-38.pyc

-26 Bytes
Binary file not shown.

game.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,18 @@
44

55
import string
66
import random
7+
import requests
78

89
class Game:
910
def __init__(self):
1011
self.grid = []
1112
for _ in range(9):
1213
self.grid.append(random.choice(string.ascii_uppercase))
1314
def is_valid(self, word):
14-
if not word:
15-
return False
16-
letters = self.grid.copy() # Consume letters from the grid
17-
for letter in word:
18-
if letter in letters:
19-
letters.remove(letter)
20-
else:
21-
return False
22-
return True
15+
return self.__check_dictionary(word)
16+
@staticmethod
17+
def __check_dictionary(word):
18+
response = requests.get(f"https://wagon-dictionary.herokuapp.com/{word}")
19+
json_response = response.json()
20+
return json_response['found']
2321

226 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)