Python won't break from a while True
<p>this is my code but as the title says I can not break and if I put something outside the while True and lives go below 0 nothing happens.    </p>

<pre><code>from random import randint
    import sys
    value = int(randint(1,10))
    lives = int(5)
    userinp = int(0)
    if lives == 0:
        print("no lives :(")
    while True:
        if lives != 0:
            print(value)
            print("You currently have: ", lives, " lives left")
            userinp = input("Please enter a number from 1 to 10: ")
            if int(userinp) == int(value):
                print("Well done you wn :D")
                sys.exit()
            elif int(userinp) &gt; int(value):
                print("Your guess was too high please guess again")
                lives = lives - 1
            elif int(userinp) &lt; int(value):
                print("Your guess was too low please guess again")
                lives = lives - 1
    if lives == 0:
        print("this")
</code></pre>

<p>This is my solution, you can set the <code>break</code> condition specifically to end your while loop if a specific event occurs.</p>

<pre><code>while lives &gt; 0:
    print(value)
    print("You currently have: ", lives, " lives left")
    userinp = input("Please enter a number from 1 to 10: ")
    if int(userinp) == int(value):
        print("Well done you wn :D")
        sys.exit()
    elif int(userinp) &gt; int(value):
        print("Your guess was too high please guess again")
        lives = lives - 1
    elif int(userinp) &lt; int(value):
        print("Your guess was too low please guess again")
        lives = lives - 1


print("this")
</code></pre>

python