Mensanator wrote:
It hasn't. and here's why:
IDLE 2.6b1
seq=['a','n','n','a']
seq.reversed()
Traceback (most recent call last):
File "", line 1, in
seq.reversed()
AttributeError: 'list' object has no attribute 'reversed'
My apologies. reversed() is a builtin func, not a method, a
On Jul 12, 2:18�pm, Terry Reedy <[EMAIL PROTECTED]> wrote:
> Peter Otten wrote:
> > Denis Kasak wrote:
>
> >> Basically, it reverses the list in place, so it modifies the list which
> >> called it. It does not return a /new/ list which is a reversed version
> >> of the original, as you expected it
Peter Otten wrote:
Denis Kasak wrote:
Basically, it reverses the list in place, so it modifies the list which
called it. It does not return a /new/ list which is a reversed version
of the original, as you expected it to. Since it doesn't return anything
explicitly, Python makes it return None
Peter Otten wrote:
Denis Kasak wrote:
Basically, it reverses the list in place, so it modifies the list which
called it. It does not return a /new/ list which is a reversed version
of the original, as you expected it to. Since it doesn't return anything
explicitly, Python makes it return None.
Denis Kasak wrote:
> Basically, it reverses the list in place, so it modifies the list which
> called it. It does not return a /new/ list which is a reversed version
> of the original, as you expected it to. Since it doesn't return anything
> explicitly, Python makes it return None. Hence, the com
On Jul 11, 6:20 pm, Mensanator <[EMAIL PROTECTED]> wrote:
> > Try this:
>
> > spam = ['a', 'n', 'n', 'a']
> > eggs = spam[:]
> > if spam.reverse() == eggs:
> > print "Palindrome"
>
> You could also do
>
> >>> spam = ['a','n','n','a']
> >>> if spam == [i for i in reversed(spam)]:
>
> pri
> Basically, it reverses the list in place, so it modifies the list which
> called it. It does not return a /new/ list which is a reversed version of
> the original, as you expected it to. Since it doesn't return anything
> explicitly, Python makes it return None. Hence, the comparison you are doin
On Jul 11, 5:34 pm, Denis Kasak <[EMAIL PROTECTED]>
wrote:
> On Sat, Jul 12, 2008 at 12:22 AM, kdt <[EMAIL PROTECTED]> wrote:
>
> > Hi all,
> >
> > Can someone please explain to me why the following evaluates as false?
> >
> list=['a','n','n','a']
> list==list.reverse()
> False
>
Denis Kasak:
> spam = ['a', 'n', 'n', 'a']
> eggs = spam[:]
> if spam.reverse() == eggs:
> print "Palindrome"
An alternative version:
>>> txt = "anna"
>>> txt == txt[::-1]
True
>>> txt = "annabella"
>>> txt == txt[::-1]
False
Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-
On Jul 11, 11:34 pm, Denis Kasak <[EMAIL PROTECTED]>
wrote:
> On Sat, Jul 12, 2008 at 12:22 AM, kdt <[EMAIL PROTECTED]> wrote:
>
> > Hi all,
> >
> > Can someone please explain to me why the following evaluates as false?
> >
> list=['a','n','n','a']
> list==list.reverse()
> False
On Sat, Jul 12, 2008 at 12:22 AM, kdt <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> Can someone please explain to me why the following evaluates as false?
>
list=['a','n','n','a']
list==list.reverse()
False
>
> I'm stumped :s
Read the documentation on list.reverse().
Basically, it reverse
Hi all,
Can someone please explain to me why the following evaluates as false?
>>>list=['a','n','n','a']
>>>list==list.reverse()
>>>False
I'm stumped :s
--
http://mail.python.org/mailman/listinfo/python-list
12 matches
Mail list logo