Emile van Sebille schreef:
On 5/13/2009 9:25 AM Timo said...
Hello,
I don't think this should be difficult, so maybe I look over it. But
I can't seem to find the solution.
I have a list with one word and a couple of numbers.
If this is always the case you can use the sort method of lists, then
relocate the last entry to the front --
>>> a = [4, 6, 'word', 3, 9]
>>> a.sort()
>>> a.insert(0,a.pop())
>>> a
['word', 3, 4, 6, 9]
>>>
Thanks all for your answers. I think I will go for this solution (should
have come to it myself).
Thanks,
Timo
HTH,
Emile
Now I want the word to be kept in the first location and the numbers
to be sorted.
So this:
[4, 6, 'word', 3, 9]
should be:
['word', 3, 4, 6, 9]
Timo
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor