I recently got into learning how to program with python (I've been learning for like 1 week or so) and I was programming this number guesser game where the computer is the one who guesses, then I got this error. Sorry if my code is a mess, I went nuts with the error and started doing random stuff, please help!
import random
guesses = 0
play = input("Do you want to play? Please enter Yes or No.").lower()
if play == "yes":
input2 = input("Please write the maximum whole number that the computer can guess from, it has to be higher than 0 and lower than 50.")
try:
int_number = int(input2)
if int_number > 0 and int_number < 50:
print(int_number)
#ERROR
pc_guess = int_number.randint(1, int_number)
print(pc_guess)
ans = input("Is this the number you're thinking?").lower()
if ans == "yes":
print("YAY, I WON!")
elif ans == "no":
user_answer = input("Damn it, is the number I guessed higher or lower than the number you're thinking?").lower()
else:
print("Please only write higher/lower!")
elif int_number > 50:
print("The number has to be lower than 50!")
elif int_number < 0:
print("The number has to be higher than 0!")
except:
print("That's not a whole number!")
elif play == "no":
print("See you later then!")
else:
print("Please only write yes/no.")
Aucun commentaire:
Enregistrer un commentaire