11 lines
379 B
Python
11 lines
379 B
Python
"""
|
|
定义一个空列表,通过for循环遍历列表
|
|
通过for循环将列表的元素添加至集合
|
|
my_list = ["黑马程序员",“传智播客”,“黑马程序员”,“it黑马”,“it黑马”]
|
|
"""
|
|
|
|
my_set =set()
|
|
my_list = ["黑马程序员","传智播客","黑马程序员","it黑马","it黑马"]
|
|
for element in my_list:
|
|
my_set.add(element)
|
|
print(my_set) |