I am trying to create a program where the user chooses a number between 1-100 and the computer tries to guess it in as few tries as possible. I think I am close but still need some help. Any and all help is appreciated. The code i have so far is pasted below....
import random print("In this game you will guess a number and the computer will try to guess it in as few tries as possible.") number = int(input("\n\nEnter a number 1-100 --- ")) cNumber = random.randint(1, 100) placeholder = cNumber tries = 1 print(number, cNumber, tries, placeholder) print("\nThe computer guessed ",cNumber) while cNumber != number: if cNumber > number: cNumber = random.randint(1,placeholder) tries += 1 print("\nThe computer guessed",cNumber) if cNumber < number: cNumber = random.randint(placeholder, 1) tries +=1 print("\nThe computer guessed",cNumber) print("The computer guessed your number in this many tries --- ",tries)