Returning a List
Terry Reedy
tjreedy at udel.edu
Fri Oct 3 15:07:05 EDT 2014
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
More information about the Python-list
mailing list