Your code did not pass our answer checks(Pyspark)

Screen Link:

My Code:

raw_hamlet = sc.textFile("hamlet.txt")
split_hamlet = line: line.split('\t'))

def cleaner(element):
    element[0] = element.partition('@')[-1]
    return element 

hamlet_with_ids = 

I thought this is one of answers for this mission, but I got an message saying “Your code did not pass our answer checks”. Does this mean that my answer is wrong? Or it is related to the answer checking system?

Your code was’t correct. check the solution code.
hamlet_with_ids = you define the function cleaner() as def cleaner(element): that means it take an input called element, and you didn’t pass any argument to this parameter element when you are calling it inside the map function. And you have to use a lambda function with line variable to retrieve each line of your text file “hamlet.txt” mapping the function (to be created) with each line of the text file.

Here are a couple different ways to make this approach work. Pretty slick conversion really. The biggest thing was just that the function needs to be applied as a lambda function… I think.

def cleaner(element):
    element[0] = element[0].partition('@')[-1]
    return element 

hamlet_with_ids = x: cleaner(x))


def clean(x):
    start = x[0]
    clean = start.partition('@')[-1]
    rest = x[1:]
    y = [clean] + rest
    return y

hamlet_with_ids = x: clean(x))