Python programming about list -
this question has answer here:
- removing duplicates in lists 30 answers
in program want remove duplicate values list. wrote:
list = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] def loop(): in range(len(list)-1): b in range(a+1,len(list)): if list[a] == list[b]: del list[a] print(list) loop()
but, it's giving me error:
can me?
if have numpy
can (i renamed list l
avoid ambiguity):
import numpy np l = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] l_no_duplicates = list( np.unique(l) )
Comments
Post a Comment