# Define a function to filter a single value

def

ten

(

value

):

"""Return whether value is below ten.

Args:

value (int): A number.

Returns:

bool: Whether `value` is less than ten.

"""

if

(

value

<

10

):

return

True

else

:

return

False

# The ten function could also be written concisely as: def ten(value): return value < 10

# Pass the function ten to the filter transformation

# Filter is a transformation so no tasks are run

filteredRDD

=

subRDD

.

filter

(

ten

)

# View the results using collect()

# Collect is an action and triggers the filter transformation to run

print

filteredRDD

.

collect

()