最近/usr/share/dict/words
、自分のメソッドを使用してパリンドロームのリストを循環して返すメソッドをispalindrome(x)
作成しました。ここにコードの一部を示します...何が問題になっていますか?10分間停止してから、ファイル内のすべての単語のリストを返します。
def reverse(a): a[::-1]を返します def ispalindrome(a): b = reverse(a) b.lower()== a.lower()の場合: Trueを返す そうしないと: Falseを返します wl = open('/ usr / share / dict / words'、'r') ワードリスト=wl.readlines() wl.close() ワードリストのxの場合: ispalindrome(x)でない場合: wordlist.remove(x) ワードリストを印刷する