Q:

How would I be able to assign a random integer to a variable?

I have been trying to assign a random number to a variable, such as health or luck but it never seems to work as when I print the variable it just says it's not defined. I would greatly appreciate any help with this. Thank you very much.
from random import randint

def ageroll():
    age= int(input("How old will you be?"))
    if age <= 0:
        print("Input a valid number from 1 to 120")
        ageroll()
    elif age <= 18:
        health = randint(1,4)
        agility = randint(4,8)
        strength = randint(1,2)
        luck = randint(1,10)
        endurance = randint(2,4)
        intelligence = randint(1,5)
        charm = randint(1,7)
        return(health,agility,strength,luck,endurance,intelligence,charm)
    elif age <= 35:
        health = randint(4,10)
        agility = randint(5,9)
        strength = randint(5,10)
        luck = randint(1,10)
        endurance = randint(4,8)
        intelligence = randint(3,10)
        charm = randint(4,7)
    elif age <= 56:
        health = randint(4,8)
        agility = randint(3,6)
        strength = randint(3,10)
        luck = randint(1,10)
        endurance = randint(5,8)
        intelligence = randint(5,10)
        charm = randint(6,10)
    elif age <= 78:
        health = randint(2,5)
        agility = randint(2,5)
        strength = randint(2,6)
        luck = randint(1,10)
        endurance = randint(1,4)
        intelligence = randint(6,10)
        charm = randint(5,6)
    elif age <= 101:
        health = randint(1,5)
        agility = randint(1,4)
        strength = randint(1,4)
        luck = randint(4,10)
        endurance = randint(3,9)
        intelligence = randint(3,10)
        charm = randint(4,7)
    elif age <= 120:
        health = randint(1,2)
        agility = randint(1,3)
        strength = randint(1,4)
        luck = 10
        endurance = randint(6,8)
        intelligence = randint(10,10)
        charm = randint(6,10)
    else:
        print("Input a valid number from 1 to 120")
        ageroll()

A:

You have to return your variables, and assign this return-value to a variable again, to use it:
from random import randint

PROPERTY_RANGES = [
    (18, dict(health=(1,4), agility=(4,8), strength=(1,2), luck=(1,10), endurance=(2,4), intelligence=(1,5), charm=(1,7))),
    (35, dict(health=(4,10), agility=(5,9), strength=(5,10), luck=(1,10), endurance=(4,8), intelligence=(3,10), charm=(4,7))),
    (56, dict(health=(4,8), agility=(3,6), strength=(3,10), luck=(1,10), endurance=(5,8), intelligence=(5,10), charm=(6,10))),
    (78, dict(health=(2,5), agility=(2,5), strength=(2,6), luck=(1,10), endurance=(1,4), intelligence=(6,10), charm=(5,6))),
    (101, dict(health=(1,5), agility=(1,4), strength=(1,4), luck=(4,10), endurance=(3,9), intelligence=(3,10), charm=(4,7))),
    (120, dict(health=(1,2), agility=(1,3), strength=(1,4), luck=(10,10), endurance=(6,8), intelligence=(10,10), charm=(6,10))),
]

def ageroll():
    while True:
        age = int(input("How old will you be?"))
        if 0 < age <= 120:
            break
        print("Input a valid number from 1 to 120")
    for max_age, values in PROPERTY_RANGES:
        if age <= max_age:
            break
    return {k: randint(*r) for k, r in values.items()}

properties = ageroll()
print(properties['health'])

