I'm not sure what I'm doing wrong because it seems I have all of the necessary components. Any advice would be greatly appreciated. Here's my code so far. Thank you!
# Reverse number-guessing game
# The player picks a random number between 1 and 100
# and the computer has to guess.
print("\t\t\tWelcome to the reverse 'guess my number' game!")
print("\nThe game where you pick a number between 1 and 100.")
print("\nThe computer must guess the number correctly.")
import random
low_number = 0
high_number = 100
response = ""
computer_guess = random.randint(low_number, high_number)
while response != "correct";
print("Is it ", computer_guess, "?")
response = input()
if response == "higher";
low_number = computer_guess + 1
computer_guess = random.randint(low_number, high_number)
elif response == "lower":
high_number = computer_guess - 1
computer_guess = random.randint(low_number, high_number)
elif response == "correct":
print("Yes!! Computers rock!")
break
input("\n\nPress the enter key to exit.")
Aucun commentaire:
Enregistrer un commentaire