Get the common values between two text files
Global variables (dataset1 and dataset2) are bad.  I'd rather see you write no function at all than a function that accepts its inputs through global variables:

with open('file1.txt') as file1, open('file2.txt') as file2:
    print((set(file1) &amp; set(file2)) or "No common elements")


If you do write a function, then it should accept its inputs as parameters.  Name the function's parameters however you want, but avoid unnecessary reassignments like a_set = dataset1 and b_set = dataset2.

def print_common_members(a, b):
    """
    Given two sets, print the intersection, or "No common elements".
    """
    print((a &amp; b) or "No common elements")

with open('file1.txt') as file1, open('file2.txt') as file2:
    dataset1 = set(file1)
    dataset2 = set(file2)
    print_common_members(dataset1, dataset2)