我的最后两个elif/else语句无法执行,我不知道为什么?
我在下面的代码中的最后一个 elif 和 else 语句有一个相当简单的问题......它们根本不会执行。我是 python 的大菜鸟,所以很可能是一个简单的错误:/控制台不显示任何语法错误或任何东西......它执行代码,但结果错误
starthandvalue = 0
if splitfirstcard[0] == splitsecondcard[0]:
ispar = True
if (splitfirstcard[0] and splitsecondcard[0] == 'A') or (splitfirstcard[0] and splitsecondcard[0]== 'K') or (splitfirstcard[0] and splitsecondcard[0] == 'Q'):
starthandvalue =+83
elif (splitfirstcard[0] and splitsecondcard[0] == 'J') or (splitfirstcard[0] and splitsecondcard[0] == '10') or (splitfirstcard[0] and splitsecondcard[0] == '9'):
starthandvalue =+75
elif (splitfirstcard[0] and splitsecondcard[0] == '8') or (splitfirstcard[0] and splitsecondcard[0] == '7') or (splitfirstcard[0] and splitsecondcard[0] == '6') or (splitfirstcard[0] and splitsecondcard[0] == '5'):
starthandvalue ==+62
else:
starthandvalue ==+55
输出
['Q', 's'] ['Q', 'h']
Hand value: about 83%
['9', 's'] ['9', 'h']
Hand value: about 75%
['6', 's'] ['6', 'h']
Hand value: about 0% <--- this should be 62
['2', 's'] ['2', 'h']
Hand value: about 0% <--- this should be 55
['3', 's'] ['3', 'd']
Hand value: about 0% <--- this should be 55
['K', 's'] ['K', 'd']
Hand value: about 83%
```
回答
将诸如=+和之类的运算符更改==+为+=