# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

class Stack():
    def __init__(self,stones):        
        self.stones = stones
    
    def __str__(self):
        return "There are {} stones left".format(len(self.stones))    # only need 'self.stones' (only had self.Stack.stones)

    def still_has_stones(self):
        return len(self.stones) != 0
    
    #remove stone should be here, rather than in Player class
    def remove_stone(self, drawn_stones):        # missed 'drawn_stones' in the arguments declaration. if it was in player class, do i still need it?
        for i in range(drawn_stones+1):
            self.stones.pop()                    # i dont need Slack.stones since i am in Stack already ? 
       


class Player():

    def __init__(self,name):
        self.name = name
    
    def choice(self):
        drawn_stones = int(input("{} Would you like to remove 1 or 2 stones?".format(self.name)))
        #assert drawn_stones < 3, "invalid input, chose between 1 and 2" 
        return drawn_stones



# +
import random
Player1 = Player("Player1")
Player2 = Player("Player2")
list_of_stones = list(range(1,21))                 # i did this - whic is ok - list_of_stones = Stack(list(range(1,21)))
stack = Stack(list_of_stones)                      # ok - missed that one - makes sense
             
while stack.still_has_stones():
    print('-'*100)
    
    Player1_Choice = Player1.choice()
    if len(stack.stones) > Player1_Choice: 
        stack.stones.append(stack.remove_stone(Player1_Choice))         # missed that one - this one is crucial
                                                                        # I did  " Stack.append(remove_stone())  "
                                                                        # ok we use choice = drawn stones
        print(stack)                                                    # i would have thought print(Stack()) - ok then
    else:
        break
    
    Player2_Choice = Player2.choice()
    if len(stack.stones) > Player2_Choice:
        stack.stones.append(stack.remove_stone(Player2_Choice)) 
        print(stack)
    else:
        break
              
print("Game Over")
# -



StarcoderdataJupyterScriptsDedupFiltered