jeudi 31 août 2017

if statement not working as expected

Hello again. I have got my mastermind game working. I have tried to implement difficulty levels, but this section always goes to the else statement no matter what i do.

def ask_number(self):
    while True:
        sleep(0.5)

Here is where it keeps skipping the if. Even when it is true.

        if self.difficulty == "hard":
            guess = input("Guess the number: ")
            self.guess = guess
            if len(guess) == len(str(self.number)):
                return True
            else:
                return "That is an invalid number!"
        else:
            return "Cant find difficulty"

I am not to sure why, but it is driving me mad now!

Aucun commentaire:

Enregistrer un commentaire