Simple application example of the python list set dict

list.count (x): Returns the number of times specified element x appears in the list

set (list): The list type variable into set types, remove duplicates

dick: save key-value pairs

= X [1,2,2,3,3 ] 
S1 = SET (X)   # set free duplicate values 
D1 = {}
 for I in S1: 
    D1 [I] = x.count (I)   # COUNT function 
print (D1)   # {. 1:. 1, 2: 2,. 3: 2}

 

Guess you like

Origin www.cnblogs.com/imhuanxi/p/10994781.html