Weird behaviour when running the script
<p>I started to code a guess the number type of game. When I execute the program, it either flows perfectly, either doesn't work...</p>

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

print("Welcome to guess the number!\nDo you want to play the game?")

question = input("")

if question == "Yes".lower():
print("Sweet! Let`s begin!\nGuess the number between 1 and 10!")

    number = random.randint(1, 10)
    guess = int(input("Take a guess!\n"))

    if guess &gt; number:
        print("Your guess is too high")
        guess = int(input("Take a guess!\n"))

    if guess &lt; number:
        print("Your guess is too low")
        guess = int(input("Take a guess!\n"))

    if guess == number:
        print("Your guess was correct!")

elif question == "No".lower():
    print("Too bad! Bye!")
    quit()
</code></pre>

<p>I absolutely no idea whether it happens because of the code, or pycharm is to blame! </p>

<p>Here is a variation on the 2 themes already offered as answers.<br>
In this option the guessing part is defined as a function, which allows us to offer the option of repeatedly playing the game until the user is bored stiff!
The other option offered is to not require the user to input "yes" or "no" but simply something that starts with "y" or "n".</p>

<pre><code>from random import randint

def game():
    print("Guess the number between 1 and 10!")
    number = randint(1, 10)
    guess = None
    while guess != number:
        guess = int(input("Take a guess!\n"))
        if guess &gt; number:
            print("Your guess is too high")
        elif guess &lt; number:
            print("Your guess is too low")
        else:
            print("Your guess was correct!")

    return input("Another game y/n ") #return a value which determines if the game will be repeated

print("Welcome to guess the number!\nDo you want to play the game?")
question = input("")
repeat = "y" # define repeat so that the first iteration happens

if question.lower().startswith('y') == True:
    print("Sweet! Let`s begin!")
    while repeat.lower().startswith('y') == True: # while repeat == "y" keep playing
        repeat = game() # play the game and set the repeat variable to what is returned
print("Bye Bye!")
</code></pre>

python pycharm