Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
582 B
12
Indexable
import random

def comp_guess(x):
    low = 1
    high = x
    feedback = ''
    while feedback != 'c':
        if low <= high:
            guess = random.randint(low, high)
        else:
            guess = low
        feedback = input(f"Is {guess} too high (H), too low (L), or correct (C)?: ")
        if feedback == "H":
            high = guess - 1
        elif feedback == 'L':
            low = guess + 1
        elif feedback == "C":
            print(f"The Computer Has Correctly Guessed Your Number, {guess}!")
            break
print(comp_guess(600))