"ast" <nom...@invalid.com> writes: > 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]: > > it doesn't work, the test always fails. Why ?
Because very often methods **dont't** return the object they are applied (self that is). This works though: >>> box = [1,3,2] >>> sorted(box) == [1,2,3] True hth, ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- https://mail.python.org/mailman/listinfo/python-list