list.reverse()

Arnaud Delobelle arnodel at googlemail.com
Mon Apr 28 14:44:16 EDT 2008


Mark Bryan Yu <vafada at gmail.com> writes:

> This set of codes works:
>
>>>> x = range(5)
>>>> x.reverse()
>>>> x
> [4, 3, 2, 1, 0]
>
> But this doesn't:
>
>>>> x = range(5).reverse()
>>>> print x
> None
>
> Please explain this behavior. range(5) returns a list from 0 to 4 and
> reverse just reverses the items on the list that is returned by
> range(5). Why is x None (null)?

have you tried typing help(list.reverse) at the interactive prompt?

-- 
Arnaud



More information about the Python-list mailing list