In python 3+:
import random
secret_number = random.randint(1,10)
guess_one = int(input("Enter player one's guess: "))
guess_two = int(input("Enter player two's guess: "))
if abs(guess_one - secret_number) < abs(guess_two - secret_number):
print(f"The secret number is {secret_number} and player 1 was closest")
elif abs(guess_one - secret_number) > abs(guess_two - secret_number):
print(f"The secret number is {secret_number} and player 2 was closest")
else:
print(f"The secret number is {secret_number} and it was a tie")
I hope this helps!