morn66 Posted May 29, 2019 Share Posted May 29, 2019 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 Quote Link to comment Share on other sites More sharing options...
anim Posted May 29, 2019 Share Posted May 29, 2019 you can convert it to set and back uniqueV = list(set(v)) 1 1 Quote Link to comment Share on other sites More sharing options...
morn66 Posted May 29, 2019 Author Share Posted May 29, 2019 wow, easy like that! Thanks!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.