title: How can I create key-value pairs?
body: <p>I have used <code>groupByKey</code> on my key-value pairs. Now I have this (key, Iterable).
  I want to make these key-value pairs from it: ((key,(one element of list)),1) for all list v.</p>
  
  <p>How can I do this? How can loop on iterable list?</p>
  
   
  
  <pre><code>val lines = sc.textFile("followers.txt").map(s =&gt; {
    val substrings = s.split(" ")
    (substrings(0), substrings(1))
  })
  val aggrigateNeighbors = lines.groupByKey().collect().foreach(println)
  val friends = aggrigateNeighbors.flatMap{x=&gt;((k,v.hasNext()),1)}
  </code></pre>