Search the web
Sign In
New User? Sign Up
python-ce · Python Windows CE
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Re: Digest Number 238   Message List  
Reply | Forward Message #824 of 1811 |
"V.C.Sekhar" vcsekhar007@... wrote:
Subject: Array programming

Hi there,
I couldnt get to do the following task using Python. Can some
pls
suggest me a way to do this.

I have an array with duplicate strings filled in it. Now am
looking for
a way to extract only the DISTINCT Values from that array.

Could some one pls help me out.

Hmmm... well the definition of the "best" way would depend on how
important readability, speed etc. were to you, and somewhat a matter of
taste as well.

For me, the most "natural" implementation would be

Create an empty list.
Iterate over the elements of the array.
For each element of the array if it is not in the list then add it.

Then you end up with a list of distinct elements.

Eg.
unique = []
for elt in array_of_strings:
if elt not in unique: unique.append(elt)






Sat May 7, 2005 11:12 pm

patrick_j_keogh
Online Now Online Now
Send Email Send Email

Forward
Message #824 of 1811 |
Expand Messages Author Sort by Date

"V.C.Sekhar" vcsekhar007@... wrote: Subject: Array programming Hi there, I couldnt get to do the following task using Python. Can some pls suggest me a...
Patrick Keogh
patrick_j_keogh
Online Now Send Email
May 7, 2005
11:12 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help