Python Script Loop
<p>I wrote the following python script to implement my version of the game nims/stones</p>

<pre><code>def nims_stones(pile, max_stones):

    while pile !=  0:

        move = 0

        while move &lt; 1 or move &gt; max_stones:
            move = int(raw_input("Player 1 How Many Stones"))
        pile -= move

        if pile == 0:
            print "Player 1 wins"

        else:
            print "There are %s stones left." %(pile)



        move = 0

        while move &lt; 1 or move &gt; max_stones:
            move = int(raw_input("Player 2 How Many Stones"))
        pile -= move

        if pile == 0:
            print "Player 2 wins"

        else:
            print "There are %s stones left." %(pile)

    print "Game Over"
</code></pre>

<p>When I call the function nims_stones(10,5) It seems to work but after player one or player two wins it doesn't exit the loop it doesn't print "Game Over" it just asks for the next move</p>

<p>I don't know why it doesn't exit the loop after a player wins. Any help will be greatly appreciated.</p>

<p>Adding a break statement after each player wins will solve your problem. You should also consider adding logic for when the pile reaches a negative value.</p>

<pre><code>while pile !=  0:

    move = 0

    while move &lt; 1 or move &gt; max_stones:
        move = int(raw_input("Player 1 How Many Stones"))
    pile -= move

    if pile == 0:
        print "Player 1 wins"
        break
    else:
        print "There are %s stones left." %(pile)



    move = 0

    while move &lt; 1 or move &gt; max_stones:
        move = int(raw_input("Player 2 How Many Stones"))
    pile -= move

    if pile == 0:
        print "Player 2 wins"
        break
    else:
        print "There are %s stones left." %(pile)

print "Game Over"
</code></pre>

python