1

Im having a rather simple problem with a my last elif and else statements in the following code... they simply wont execute. Im a big noob with python so it can be very likely its a simple mistake :/ the console dosnt show any syntax error or anything... it executes the code, but with the wrong result

            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

OUTPUT

['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%
```
Jaysmito Mukherjee
  • 1,467
  • 2
  • 10
  • 29
Kexxler
  • 23
  • 4

2 Answers2

5

Change the operators such as =+ and ==+ to +=

Timur Shtatland
  • 12,024
  • 2
  • 30
  • 47
2

Quick glance, splitfirstcard[0] and splitsecondcard[0] == '5' doesn't mean what you think. These statements should be splitfirstcard[0] == 5 and splitsecondcard[0] == '5'

Example:

t1 = 'a'
t2 = 'b'
t1 and t2 == 'b'
Out: True

t1 == 'b' and t2 == 'b'
Out: False
Ghoti
  • 737
  • 4
  • 19