dimanche 28 octobre 2018

What is wrong with my if test, and why wont my program continue?

(Python)

I am making a small guess game, and something is not right with my if test. I cant see what is worng with it. Why do it not print: "You found the number!", when i guess the right number? And how can i get it to continue to ask the question after guessing the wrong number?

This is what i have:

import random
for x in range(1):
    randomNumber = random.randint(0,10)

print(randomNumber)

print("Guess the right number:")
yourNumber = input()

print(yourNumber)

if(yourNumber == randomNumber):
  print("You found the right number!")
elif yourNumber != randomNumber:
  print("Guess one more time")
  yourNumber = input()

Aucun commentaire:

Enregistrer un commentaire