, 16: 4, 15: 2}
[24, 16, 15]
[15, 16, 24]
[24, 16, 15]
Respectfully,
Jacob Schmidt
- Original Message -
From: "Jonas Melian" <[EMAIL PROTECTED]>
To:
Sent: Tuesday, August 23, 2005 8:25 AM
Subject: [Tutor] Sort a Set
>I get a list of repeated numbers [24, 24, 24, 16
On Tue, 23 Aug 2005, Kent Johnson wrote:
> Actually the reverse parameter is new in 2.4 too, you have to do that in
> a separate step also:
Doh!
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
I've done:
undup = []
for i in list:
if i not in undup:
undup.append(i)
Which is simple an not very pythonic, but does the trick.
Hugo
Jonas Melian wrote:
> I get a list of repeated numbers [24, 24, 24, 16, 16, 15, 15 ]
> Is possible get it without repeated numbers, without usi
Terry Carroll wrote:
> Sorry, I missed you were on 2.3.x, and I think sorted() is new with 2.4.
> You'd instead have to do the sort in a separate step:
>
>
l=[24, 24, 15, 16, 16, 15, 24]
l=list(set(l))
l.sort(reverse=True)
l
>
> [24, 16, 15]
Actually the reverse parameter is n
On Tue, 23 Aug 2005, Terry Carroll wrote to Jonas:
> I don't know if you're in a position to rely on the sortedness of the
> input data, but even if not, this works:
>
> >>> l=[24, 24, 15, 16, 16, 15, 24]
> >>> l=sorted(list(set(l)), reverse=True)
> >>> l
> [24, 16, 15]
Sorry, I missed you were
On Tue, 23 Aug 2005, Jonas Melian wrote:
> I get a list of repeated numbers [24, 24, 24, 16, 16, 15, 15 ]
> Is possible get it without repeated numbers, without using set()?
>
> If I use set, then the list is unsorted and i cann't sorting it.
Converting it to a set will eliminate dupes, and con
Jonas Melian wrote:
> I get a list of repeated numbers [24, 24, 24, 16, 16, 15, 15 ]
> Is possible get it without repeated numbers, without using set()?
>
> If I use set, then the list is unsorted and i cann't sorting it.
>
> A idea it would be create a generator that will return elements one by
I get a list of repeated numbers [24, 24, 24, 16, 16, 15, 15 ]
Is possible get it without repeated numbers, without using set()?
If I use set, then the list is unsorted and i cann't sorting it.
For get the values i use:
[x[0] for x in cardTmp]
or:
from itertools import imap
for i in imap(lamb