mylist = [2, "hello", "老鸟", "python", "老鸟python", "hello", 2, "hello", "python", 2] dict_new = {} for i in mylist: if i not in dict_new: dict_new[i]=1 else: dict_new[i]+=1
mylist = [2, "hello", "老鸟", "python", "老鸟python", "hello", 2, "hello", "python", 2] dict_new = {} for i in mylist: if i not in dict_new: dict_new[i]=1 else: dict_new[i]+=1