lundi 16 octobre 2017

Python random variable not properly working [duplicate]

This question already has an answer here:

Helloo

I'm trying to make a simple game where you have to choose either 1 or 2 and one of them is correct. I've used a simple random generator to choose either 1 or 2 as the correct answer.

def guess():

print("")
print("Select a number, 1 or 2")
print("")
from random import randint
ran = randint(1, 2)
nmr = input("")
if nmr == ran:
    print("That's correct!")
else:
    print("Wrong number")

Every time I answer it prints "Wrong number".

I've also tried printing the random number before answering but it still takes it as incorrect. Any idea what is wrong there?




Aucun commentaire:

Enregistrer un commentaire