I have some code that takes overlapping elements from two lists and creates a new one with these elements. there are two functions which check for a valid input, however, the return statement returns no value to the main function. Can someone help me?
This is the code:
import random
import sys
def try_again():
    d = input("\nTry again? (y/n): ")
    if d == 'y':
        main_func()
    elif d != 'y' and d != 'n':
        print("Invalid entry")
        try_again()
    elif d == 'n':
        sys.exit()
def first_list_test(length_a, range_a):
    length_a = int(input("Enter the length of the first random list: "))
    range_a = int(input("Enter the range of the first random list: "))
    if length_a > range_a:
        print("The length of the list must be greater than the range for unique elements to generate")
        first_list_test(length_a, range_a)
    else:
        print("Length: " + str(length_a))
        print("Range: " + str(range_a))
    return length_a, range_a
def second_list_test(length_b, range_b):
    length_b = int(input("Enter the length of the second random list: "))
    range_b = int(input("Enter the range of the second random list: "))
    if length_b > range_b:
        print("The length of the list must be greater than the range for unique elements to generate")
        second_list_test(length_b, range_b)
    else:
        print("Length: " + str(length_b))
        print("Range: " + str(range_b))
    return length_b, range_b
def main_func():
    length_a = int()
    range_a = int()
    first_list_test(length_a, range_a)
    print(length_a)
    print(range_a)
    print("\n")
    length_b = int()
    range_b = int()
    second_list_test(length_b, range_b)
    print(length_b)
    print(range_b)
    print("\n")
    a = random.sample(range(1, range_a), length_a)
    a.sort()
    b = random.sample(range(1, range_b), length_b)
    b.sort()
    num = int()
    print(a, "\n")
    print(b, "\n")
    c = []
    d = []
    for num in a:
        if num in b:
            c.append(num)
    for test_num in c:
        if test_num not in d:
            d.append(test_num)
    d.sort()
    if len(d) == 0:
        print("No matches found")
    else:
        print("Overlapping elements: ")
        print(d)
    try_again()
main_func()
 
    