Question about reversed lists in Python -


i new python, able tell.

if have list:

a = [1,2,3,2,1] 

this evaluates true:

a == a[::-1] 

...but evaluates false:

a == a.reverse() 

why case?

because .reverse() reverses list in-place , returns none:

>>> print a.reverse() none 

and a == none evaluates false.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -