私は、ユーザーに4つの異なる "単語ゲーム"を持つメニューが与えられるpythonでプログラムを書く必要があります。 dictionary.txtと呼ばれるファイルがあり、ゲームの1つでは、a)単語の文字数とb)辞書内で検索されている単語から除外する文字(dictionary.txtには辞書全体があります)。次に、プログラムはユーザーの要件に従う単語を印刷します。私の質問は、ファイルを開いてそのファイル内の特定の長さの単語を検索する方法です。私はユーザーに入力を求めるだけの基本コードしか持っていません。私はこれで非常に新しいです助けてください:( これは私が最初のオプションを持っているものです。他のものはうまくあり、ループを壊す方法を知っていますが、この特定のものは本当に私にトラブルを与えている。正直言って、誰かが楽しいと言っていたので、私はこのクラスを取っただけですが、最近は本当に遅れていて、今何をすべきか分かりません。これはイントロレベルのコースですとても素敵にしてください私は今まで前にこれをやったことがない:(ここでファイル内の特定の単語を見つける
print
print "Choose Which Game You Want to Play"
print "a) Find words with only one vowel and excluding a specific letter."
print "b) Find words containing all but one of a set of letters."
print "c) Find words containing a specific character string."
print "d) Find words containing state abbreviations."
print "e) Find US state capitals that start with months."
print "q) Quit."
print
choice = raw_input("Enter a choice: ")
choice = choice.lower()
print choice
while choice != "q":
if choice == "a":
#wordlen = word length user is looking for.s
wordlen = raw_input("Please enter the word length you are looking for: ")
wordlen = int(wordlen)
print wordlen
#letterex = letter user wishes to exclude.
letterex = raw_input("Please enter the letter you'd like to exclude: ")
letterex = letterex.lower()
print letterex
1.この宿題ですか?もしそうなら、そのようなタグを付けてください。 2.あなたがすでに持っているコードを私たちに教えてください。 3.まだ*何か試しましたか? – tzaman
また、あなたの質問を段落に分けてください。改行がなければ、あなたの質問は「テキストの壁」を想定しているため、読みにくいです。 –