The python code for this is below:
from random import randint
goal = randint(1,10) tries = 3
while tries > 0: guess = int(input("Please guess the number:")) if guess == goal: print("Congratulations you won!") break else: tries-=1 print("Incorrect! %d tries left!"%tries)