こんにちは私はPythonとプログラミングに不慣れです。ワードゲーム用のコードをいくつか作成しました。実行すると、出力の前に「なし」が出力されます。それらを削除する方法はありますか、ループが何も返さないことに関係していることはわかっていますが、可能であればコードを大幅に変更する必要はありません(最初は十分に時間がかかりました:))よろしくお願いします。
def compPlayHand(hand, wordList, n):
# Keep track of the total score
totalScore = 0
# As long as there are still usable letters left in the hand:
while compChooseWord(hand,wordList,n) is not None:
# Display the hand
print "Current Hand: ",
print displayHand(hand),
word = compChooseWord(hand,wordList,n) # comp chooses word
hand = updateHand(hand,word)
# Tell the user how many points the word earned, and the updated total score, in one line followed by a blank line
getWordScore(word,n)
totalScore += getWordScore(word,n)
# Update the hand
c = calculateHandlen(hand)
print '"'+str(word)+'"' + " earned " + str(getWordScore(word,n)) +' points.' " Total: " + str(totalScore) + " points." # Otherwise (the word is valid):
print
if compChooseWord(hand,wordList,n) is None: # End the game (break out of the loop)
print "Current Hand: ", \
displayHand(hand),
print "Total score: " + str(totalScore) + " points."