2016-12-13 22 views
-4

関数を自分自身の先頭に戻そうとするときに問題があります。私のコードは次のとおりです。関数 - TypeError: 'str'オブジェクトが呼び出し可能ではありません

Traceback (most recent call last): 
    File "[hidden]", line 330, in <module> 
    questionOne() 
    File "[hidden]", line 42, in questionOne 
    questionTwo() 
    File "[hidden]", line 53, in questionTwo 
    questionThree() 
    File "[hidden]", line 70, in questionThree 
    questionFour() 
    File "[hidden]", line 87, in questionFour 
    questionFour() 
TypeError: 'str' object is not callable 

ありがとう:私はこの問題を取得しています

def questionFour(): 
    print("") 
    global questionsCorrect 
    global questionsIncorrect 
    print ("What is 4 + 4?") 
    questionFour = input (">> ") 
    if str.isdigit(questionFour): 
     if questionFour.lower() == ("8"): 
      questionsCorrect += 1 
      questionFive() 
     else: 
      questionsIncorrect += 1 
      questionFive() 
    else: 
     print ("That's not a number!") 
     questionFour() 

+1

'questionFour()' - > 'questionFour' –

+1

*完全トレースバック*を含めて、これを引き起こした行とPythonの到達点を確認してください。 –

答えて

5

あなたはquestionFourにquestionFour = input ...という行を割り当てています。 Pythonのスコープのために、これは関数の内部でのみ有効ですが、再帰的に呼び出すことはできません。入力に異なる変数名を選択します。

+0

それはうまくいった。ありがとう! –

+0

喜んで助けてください! Stack Exchangeがあなたにできるときは、答えを受け入れてください。 –

関連する問題