Understanding reduce example:- I am new to spark and python .I am in the learning curve .The below example is given for reduce in spark documentation

can you please help me understand the below example.

sc.paralleliize :- paralleizes the input list . I didn’t understand 2 for _ .
does this represent all the numbers in the range ?. i changed the number ‘2’ to many different values but the o/p was always 10.

sc.parallelize((2 for _ range(10))).map(lambda x: 1).cache().reduce(add)
10


Learn Spark 1.6.x or Spark 2.x on our state of the art big data labs

  • Click here for access to state of the art 13 node Hadoop and Spark Cluster