How to stop script if user inputs certain characters - PYTHON
<p>I'm a beginner in programming and I'm creating a roll the dice type of game. And I want to create a command in which if the user types in Exit, the whole script would print bye and stop. I tried something like:</p>

<pre><code>commandLine = "Exit"

if commandLine == "Exit".
    print ("Bye!")
    quit()
</code></pre>

<p>But it doesn`t work at all. The script would go on.
This would be my script:</p>

<pre><code>import random
from random import randint
import re


print ("Welcome to Roll the Dice")

roll = input("Do you want to Roll the Dice? \n Yes / No \n")

if roll == "Yes".lower():
    print("Nice , let`s do it!")

elif roll == "No".lower():
    print("Too bad! :( See you later!")
    quit()

dice = input("Press 'x' to roll the dice!\n")


if dice == "X".lower():
print(random.randint(1,9))

again = input("Sweet ! Would you like to try again?\n")
while again == "Yes".lower():
    dice = input("Press 'x' to roll the dice!\n")

    if dice == "X".lower():
        print(random.randint(1, 9))

    if again == "No".lower():
        print("See you later!")
        quit()
</code></pre>

<p>try:</p>

<pre><code>while again == "yes":
    dice = input("Press 'x' to roll the dice!\n")

    if dice == "x":
        print(random.randint(1, 9))

    if dice == "no":
        print("See you later!")
        quit()
</code></pre>

python