Modify the guessing-game program so that the user thinks of a number that the computer must guess.
The computer must make no more than the minimum number of guesses, and it must prevent the user from cheating by entering misleading hints.
Use I'm out of guesses, and you cheated and Hooray, I've got it in X tries as your final output.
I code it as below,
smaller = int(input("Enter the smaller number: "))
larger = int(input("Enter the larger number: "))
myNumber = random.randint(smaller, larger)
count = 0
maxGuesses = round(math.log(larger - smaller + 1, 2))
count += 1
yourNumber = (smaller + larger) //2
print("Your number is", yourNumber)
answer = input("Enter =, <, or >: ")
if answer == "=":
print("Hooray, I've got it in", count , "tries!")
elif answer == "<":
larger = yourNumber -1
elif answer == ">":
smaller = yourNumber +1
if count < maxGuesses:
print("I'm out of guesses, and you cheated!")******
When I run this, error message says,
2 out of 3 checks passed. Review the results below for more details.
Test for 0-50, when 1 is picked then switched when correctly guessed