You do have some issues with your code. For example, nothing forces you to only enter 3 letters, or even forces those to be letters. Also, you can enter more, or less, than 4 digits, too. Anyway, this is a simple example of brute-forcing. Its just going over all the options you have, attempting to match the hash. Note that this is sub-optimal to say the least, but hey, running a brute-force in Python isn't a very smart idea to begin from so this is good enough. Note that i've selected the test password close to the beginning of the brute-forced range, otherwise you'll wait forever for this to succeed.
import hashlib, itertools
def brute_force(hash):
letters = [chr(n) for n in range(ord('A'), ord('Z'))]
digits = [chr(n) for n in range(ord('0'), ord('9'))]
for part1 in itertools.product(letters, repeat=3):
for part2 in itertools.product(digits, repeat=4):
password_try = ''.join(part1 + part2)
if hashlib.sha256(password_try.encode()).hexdigest() == hash:
return password_try
test_password = "BOO8000"
key = hashlib.sha256(test_password.encode()).hexdigest()
print("Hash: %s" % key)
print("Brute-forcing...")
recovered_key = brute_force(key)
print("Brute-force result: %s" % recovered_key)