hi there i'm learning python i like to know if this script can be better or shorter
import sys
g = 1
def trying():
    q = input('enter (y or yes) to retry')
    if not q == 'y' or q == 'yes':
        return 0
while g == True:
    try:
        t = int(input('please enter an integer:'))
        r = t % 2
        if r == 0:
            print('your number is even')
            if trying() == 0:
                g = 0
        else:
            print('your number is odd')
            if trying() == 0:
                g = 0
    except ValueError:
        print('sorry you need to enter numbers only')
 
     
     
    