2016-04-18 12 views
1

Pythonで自分の関数のいずれかが動作するのに問題があります。私の関数のコードは以下の通りです:PythonでNoneTypeエラーが発生した場合If条件

potValue, playerBalance = checkBlackjack(playerValue, potValue, playerBalance, wager) 

そして、私が取得エラーは、次のとおりです:

def checkBlackjack(value, pot, player, wager): 
    if (value == 21): 
     print("Congratulations!! Blackjack!!") 
     pot -= wager 
     player += wager 
     print ("The pot value is $", pot) 
     print ("Your remaining balance is $",player) 
     return (pot, player) 

関数呼び出しがあるとできないというエラー会談以来

potValue, playerBalance = checkBlackjack(playerValue, potValue, playerBalance, wager) 
TypeError: 'NoneType' object is not iterable 

iterate、if条件を使用してこれを関連付ける方法がわかりません。

本当にありがとうございます。ありがとう!

あなたの関数で条件が満たされた場合にのみ、何かを返すしている
+1

'value'が' 21'でないときにどうなるか自分自身に尋ねてください。 –

答えて

3

が、それ以外の機能はデフォルトでNone返し、2つの値(あなたの変数)ここで

1

Noneを解凍しようとしているがMCVEのためにありますこの質問:

>>> a, b = None 
Traceback (most recent call last): 
    File "<pyshell#2>", line 1, in <module> 
    a, b = None 
TypeError: 'NoneType' object is not iterable 

この時点で問題は明らかです。そうでない場合は、マニュアルで複数の割り当てを参照することができます。

関連する問題