Python 3 | Sorted, Max, Min Dictionary trought a ZIP, Error
<p>I'm learning python 3 and I'm trying to use zip to transform a dictionary into a zip, this way I would be able to use functions like sorted, max and min on it.</p>

<p>Stocks is the dictionary btw.
So I tested it out like this, and it worked:</p>

<pre><code>print(min(zip(Stocks.values(),Stocks.keys())))
print(max(zip(Stocks.values(),Stocks.keys())))
print(sorted(zip(Stocks.values(),Stocks.keys())))
</code></pre>

<p>Then I tried to do this:</p>

<pre><code>stock_zip = zip(Stocks.values(), Stocks.keys())
print(max(stock_zip))
print(min(stock_zip))
print(sorted(stock_zip))
</code></pre>

<p>And this was the console result but I'm rather confused why it happened:</p>

<pre><code>(520, 'GOOG')
Traceback (most recent call last):
  File "----------------------------------------------------------------", line 11, in &lt;module&gt;
    print(min(stock_zip))
ValueError: min() arg is an empty sequence
</code></pre>

<p>If anyone can explain me why the second piece of code doens't work I would be very appreciated :)</p>

<p>In python3.X <code>zip</code> returns an iterator, and once you pass it to a function actually you've consumed it, therefor when you pass it to another function you're passing an empty iterator. </p>

<pre><code>In [15]: a = zip(range(3), range(3))

In [16]: list(a)
Out[16]: [(0, 0), (1, 1), (2, 2)]

In [17]: list(a)
Out[17]: []
</code></pre>

python python-3.x