‘’’
写出一段Python代码实现删除一个list里面的重复元素
‘’’
list = ['hello', 'good', 'world', 'hello', 'kitty', 'kitty', 'hello']
new_list = []
for word in list:
if word not in new_list:
new_list.append(word)
print(new_list)
import random
li = []
for i in range(10):
ran = random.randint(1,10)
li.append(ran)
print(li)
for i in li:
if li.count(i) >= 2:
li.remove(i)
print(li)