Accumulators Udemy Course Lecture number 27 Section 4


#1

Hi All,

I have just started the course HDPCD Spark using Python. I am taking up the Udemy Course taught by Durga Sir. In the lecture number 27, Section 4, he has the following lines of code:

ordersCompleted=0

def isComplete(order, ordersCompletedCount):
isCompleted=order.split(",")[3]==“COMPLETE” or order.split(",")[3]==“CLOSED”

if(isCompleted):ordersCompletedCount=ordersCompletedCount+1
return isCompleted

ordersFiltered=orders.filter(lambda order :isComplete(order,ordersCompletedCount))

Now, when he is issuing the statement: ordersFiltered.count(), it is giving the count of the orders satisfying the condition. My question is the function isComplete is returning a boolean value, then how come the variable ordersFiltered gets the count? Also how the lambda function operates in this case?