Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #78661

Re: Returning a List

From Terry Reedy <tjreedy@udel.edu>
Subject Re: Returning a List
Date 2014-10-03 15:07 -0400
References <loom.20141003T133313-701@post.gmane.org>
Newsgroups comp.lang.python
Message-ID <mailman.14581.1412363279.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 10/3/2014 7:35 AM, Shiva wrote:
> Hi All,
>
> I might be doing something really silly here, but I can't seem to spot it:
>
> def front_x(words):
>    b=[]
>    c=[]
>    for a in words:
>       if a[0] == 'x':
>           b.append(a)
>       else:
>           c.append(a)
>
>    b = sorted(b)
>    c = sorted(c)

Just sort in place with
      b.sort()
      c.sort()

>    d= b+c
>    print('d = ',d)
>
>    #return b+c
>    return d
>
> front_x(['bbb', 'ccc', 'axx', 'xzz', 'xaa'])

xlist = front_x(['bbb', 'ccc', 'axx', 'xzz', 'xaa'])
print(xlist)

-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Returning a List Terry Reedy <tjreedy@udel.edu> - 2014-10-03 15:07 -0400

csiph-web