Python
1from random import randint 2miss = 0 3correct = 0 4print("問題!三回間違えたら終了。qで止める") 5while miss<3 : 6 a = randint(1,100) 7 b = randint(1,100) 8 ans = a + b 9 10 question = f"{a}+{b}は?" 11 value = input(question) 12 if value == "q": 13 break 14 if value == str(ans) : 15 correct += 1 16 print("正解です") 17 else : 18 miss += 1 19 print("間違い", "×"*miss) 20 21print("-"*20) 22print("正解:",correct) 23print("間違い:",miss)
これを実行した場合次のようなエラーが出てしまいます。
StdinNotImplementedError Traceback (most recent call last)
c:\Users\twvsj\OneDrive\デスクトップ\test\test.py in
9 ans = a + b
10 question = f"{a}+{b}は?"
---> 11 value = input(question)
12 if value == "q":
13 break
~\Anaconda3\lib\site-packages\ipykernel\kernelbase.py in raw_input(self, prompt)
853 if not self._allow_stdin:
854 raise StdinNotImplementedError(
--> 855 "raw_input was called, but this frontend does not support input requests."
856 )
857 return self._input_request(str(prompt),
StdinNotImplementedError: raw_input was called, but this frontend does not support input requests
このエラーを解決する方法を教えてください。
よろしくお願いします。
あなたの回答
tips
プレビュー