CodePudding user response:
peans=16
Def pickBeans (count, name) :
Global peans
If the count & gt; 3 the or count & lt; 1:
Print (" you input is wrong, please input again ")
Return False
The else:
Peans -=count
If peans & lt;=0:
Print (" % s "winning % name)
The else:
Print (" beans remaining % d star "% peans)
Return True
The prior=int (input (" input computer, the first 1 0 players under the first: "))
While peans & gt; 0:
If the prior==1:
CCount=int (input (" Computer out: "))
If not pickBeans (cCount, 'Computer') :
The continue
If peans & lt;=0:
Break
UCount=int (input (" the User take out: "))
If not pickBeans (uCount, 'User') :
The continue
If the prior==0:
UCount=int (input (" the User take out: "))
If not pickBeans (uCount, 'User') :
The continue
If peans & lt;=0:
Break
CCount=int (input (" Computer out: "))
If not pickBeans (cCount, 'Computer') :
The continue