# Help in tweaking a code

i have this below i have watched in and practiced a tutorial, however i tired to achieve the same outcome in a different logic and it has not been fairly correct. i need help with the code.
Code one allows me to get feed back if certain conditions are met, i tired the same method with code two but its not giving back the right results
Code 1
num = 32
tries = 3
guess = input("guess a number btn 1 and 50: ")
guess = int(guess)

while guess != num and tries != 0:
guess = input("guess a number btn 1 and 50: ")
guess = int(guess)
if guess == num:
print(âCongratulationsâ)
elif guess != num and tries == 1:
print(âBetter luck next timeâ)
break
elif guess > num:
tries -= 1
print(âGuessed too highâ)
else:
tries -= 1
print(âGuessed too lowâ)

Code 2

def get_age():
age = ââ
tries = 3

``````while age.isdigit() == False and tries != 0:
age = input("Your age is? ")

if age.isdigit() == True:
print(age)

elif age.isdigit() == False and tries == 1:
print("Better luck next time")
break
elif age.isdigit() == False:
tries -= 1
return int(age)
``````

get_age()

other ways i tried in images:

Youâre not using the `.isdigit()` method correctly.

As an example:

``````age = input("Your age? ")

if age.isdigit():  # this will return True if all the characters are digits, otherwise False
else:
print("That was not a integer number")
``````

Youâre also not formatting your posts correctly.

1. Donât post images please, unless you absolutely need to.
2. Fence your code block (pre-post) like this:
`````````python