title: Python - issue with using a list of frozenset entries in a for loop
body: <p>I am trying to learn the apriori machine learning algorithm from a book that uses Python, and as part of that learning, I am currently stuck with this following problem:</p>
  
  <p>The following code construct seems to work fine:</p>
  
  <pre><code>Ck = [[1], [2], [3], [4], [5]]
      for tranid in range(10): 
          for candidate in Ck:
              print("Printing candidate value: ", candidate)
  </code></pre>
  
  <p>However, the following does not work:</p>
  
  <pre><code>Ck = [[1], [2], [3], [4], [5]]
  Ck2 = map(frozenset, Ck)
      for tranid in range(10): 
          for candidate in Ck2:
              print("Printing candidate value: ", candidate)
  </code></pre>
  
  <p>When I map every element of my original iterable to a frozenset, I notice that the inner loop (<em>"for candidate in Ck2"</em>) executes only once. After that it never executes. The code above without the frozenset properly loops through the inner loop 10 times. However, with frozenset mapped, I can get the inner loop to execute only once.</p>
  
  <p>Please help me with fixing this. The book has mapped the iterable values to frozenset because they don't want it to be mutable for the purposes of the algorithm. I am simply trying to follow it as is.</p>
  
  <p>I am using Python 3.5.1 on Anaconda (Spyder).</p>
  
  <p>Please help, as I am new to both Python and Machine Learning.</p>
  
  <p>Thanks and Regards,
  Mahesh. </p>