title: Pyspark applying foreach
body: <p>I'm nooby in Pyspark and I pretend to play a bit with a couple of functions to understand better how could I use them in more realistic scenarios. for a while, I trying to apply a specific function to each number coming in a RDD. My problem is basically that, when I try to print what I grabbed from my RDD the result is None</p>
  
  <p>My code:</p>
  
  <pre><code>from pyspark import SparkConf , SparkContext
  
  conf = SparkConf().setAppName('test')
  sc = SparkContext(conf=conf)
  
  sc.setLogLevel("WARN")
  
  
  changed = []
  
  def div_two (n):
      opera = n / 2
      return opera
  
  numbers = [8,40,20,30,60,90]
  
  numbersRDD = sc.parallelize(numbers)
  
  changed.append(numbersRDD.foreach(lambda x: div_two(x)))
  
  #result = numbersRDD.map(lambda x: div_two(x))
  
  for i in changed:
      print(i) 
  </code></pre>
  
  <p>I appreciate a clear explanation about why this is coming Null in the list and what should be the right approach to achieve that using foreach whether it's possible.</p>
  
  <p>thanks </p>