Define a Function and how to call?

hi all,

i wasd trying to create a def inside python as part of bigger code i’d like to define a function but i cant get it to work, any ideas what i’m missing or what im doing wrong? see code below. Thanks.

lists = IN[0]
keys = IN[1]

def groupbyKey(lists,keys):
	uniqueKeys = set(keys)
	results = []
	for uniqueItem in uniqueKeys:
		keyGroup = []
		for element, key in zip(lists,keys):
			if key == uniqueItem:
				keyGroup.append(element)
		results.append(keyGroup)

OUT = groupbyKey(lists,keys)
def group(lists, keys):
	uniqueKeys = set(keys)
	results = []
	for uniqueItem in uniqueKeys:
	    keyGroup = []
	    for element, key in zip(lists,keys):
	        if key == uniqueItem:
	            keyGroup.append(element)
	   	results.append(keyGroup)
	return results