簡単な単語ゲームを作成しようとしていますが、プレイヤーが書き込んだ単語が辞書にあるかどうかを確認する必要があります。
今のところ、行ごとに確認できますが、あまり効果的ではないので、より良い方法があることを願っています
import csv
word = raw_input('write your word')
def dict_test(word):
with open('/home/patryk/Pulpit/slownik.csv', 'r') as dictionary:
reader = csv.reader(dictionary, delimiter = ' ')
for row in reader:
if word not in row:
print word + ' it doesnt exist in dictionary'
elif word in row:
print word + ' ### OK ### '
dict_test(word)