Reputation: 103
I am having trouble getting one of my functions in python to work. The code for my function is below:
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)
The function call is:
potValue, playerBalance = checkBlackjack(playerValue, potValue, playerBalance, wager)
And the error I get is:
potValue, playerBalance = checkBlackjack(playerValue, potValue, playerBalance, wager)
TypeError: 'NoneType' object is not iterable
Since the error talks about not being able to iterate, I am not sure how to relate this to using the if condition.
Any help will really be appreciated. Thanks!
Upvotes: 1
Views: 231
Reputation: 19174
Here is an MCVE for this question:
>>> a, b = None
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
a, b = None
TypeError: 'NoneType' object is not iterable
At this point, the problem should be clear. If not, one could look up multiple assignment in the manual.
Upvotes: 1
Reputation: 11635
You're only returning something if the condition in your function is met, otherwise the function returns None
by default and it is then trying to unpack None
into two values (your variables)
Upvotes: 3