Jump to content

Python Unique Value Array


Recommended Posts

Hi everyone,

is there an easier way to remove a same value from an array (only have uniqueval)? I have a solution so far but I'm not sure is the most efficient technique.

v = [1,8,2 2,4,4,10,4,5]
v.sort()
uniqueV = []
for i in v:
   if i not in uniqueV:
      uniqueV.append(i)
print uniqueV

Thanks

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...