<div dir="ltr"><div><div><div><div><div><div>scusatemi è vero.<br></div></div>listaspesa=( uova,proscutto,carne,rucola,patate)<br></div><div>quantita=(1,2,3,4,2)<br></div><div><br></div>Se volessi scansionare esempio il 1° elemento di "listaspesa" con il 1° elemento di "quantita". <br>Il mio output dovra essere: <br><br>uova 1 <br>prosciutto 2 <br></div>carne 3<br></div>rucola 4<br></div>patate 2<br><div><div><div><br></div><div>Come si risolve la storia? Con un for con un while ma a che condizione?<br></div><div><br></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">Il giorno 13 maggio 2015 12:15, Marco Buttu <span dir="ltr"><<a href="mailto:marco.buttu@gmail.com" target="_blank">marco.buttu@gmail.com</a>></span> ha scritto:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 12/05/2015 23:44, Gollum1 wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
Il 12 maggio 2015 20:59:40 CEST, Daniele Zambelli <<a href="mailto:daniele.zambelli@gmail.com" target="_blank">daniele.zambelli@gmail.com</a>> ha scritto:<br>
<br>
</span><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
a = [1, 2, 3, 4]<br>
b = [2, 3, 4, 5]<br>
c = [1, 2, 3, 4]<br>
a == b<br>
</blockquote></blockquote></blockquote>
False<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
a == c<br>
</blockquote></blockquote></blockquote>
True<br>
</blockquote>
  Mi pare di ricordare che questa il ultima non sia poi così scontata...<br>
</span></blockquote>
<br>
Quest'ultima e' senza dubbio vera (si confronta il valore, non l'identita')<span class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
cpython potrebbe semplificare le due liste con lo stesso oggetto, ma non è detto che lo faccia sempre è non è detto che lo facciano tutti gli interpreti... oppure ho detto una cavolata Marco Buttu?<br>
</blockquote>
<br></span>
CPython garantisce il contrario, ovvero che l'etichetta (il nome) `a` e l'etichetta `c` facciano riferimento a due oggetti (mutabili) distinti (diversa identita'). Questo e' sempre garantito per gli oggetti mutabili. Non e' garantito nel caso di oggetti immutabili [1]:<br>
<br>
<br>
Types affect almost all aspects of object behavior. Even the importance of object identity is affected in some sense: for immutable types, operations that compute new values may actually return a reference to any existing object with the same type and value, while for mutable objects this is not allowed. E.g., after a = 1; b = 1, a and b may or may not refer to the same object with the value one, depending on the implementation, but after c = []; d = [], c and d are guaranteed to refer to two different, unique, newly created empty lists. (Note that c = d = [] assigns the same object to both c and d.)<br>
<br>
<br>
[1] <a href="https://docs.python.org/3/reference/datamodel.html#objects-values-and-types" target="_blank">https://docs.python.org/3/reference/datamodel.html#objects-values-and-types</a><span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
Marco Buttu<br>
<br>
INAF-Osservatorio Astronomico di Cagliari<br>
Via della Scienza n. 5, 09047 Selargius (CA)<br>
Phone: <a href="tel:070%20711%2080%20217" value="+3907071180217" target="_blank">070 711 80 217</a><br>
Email: <a href="mailto:mbuttu@oa-cagliari.inaf.it" target="_blank">mbuttu@oa-cagliari.inaf.it</a></font></span><div class="HOEnZb"><div class="h5"><br>
<br>
_______________________________________________<br>
Python mailing list<br>
<a href="mailto:Python@lists.python.it" target="_blank">Python@lists.python.it</a><br>
<a href="http://lists.python.it/mailman/listinfo/python" target="_blank">http://lists.python.it/mailman/listinfo/python</a><br>
</div></div></blockquote></div><br></div>