On 02/26/2014 10:24 PM, ast wrote:
Hello

box is a list of 3 integer items

If I write:

   box.sort()
   if box == [1, 2, 3]:


the program works as expected. But if I write:

   if box.sort() == [1, 2, 3]:

Most such questions can be answered by printing out the values in question and observing first hand what the value is.

So, print out box.sort() to see what it is.  You might be surprised.

Hint: box.sort() does indeed cause box to be sorted, and the sorted list is left in box, but the sorted list is not returned as a function value.


it doesn't work, the test always fails. Why ?

Thx

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to