names = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
name_set = str(set(names)).lower()
print('alice' in name_set)
names = ['Alice','alice', 'Bob', 'Candy', 'David', 'Ellena'] name_set = set(names) name1 = 'bob' for i in name_set: if name1.lower() == i.lower(): print(True) else: print(False)
可以遍历集合name_set,将name_set中的元素都转化为小写,然后在进行判断.例如查看name1 = 'bob'是否在集合中
names = ['Alice','alice', 'Bob', 'Candy', 'David', 'Ellena'] name_set = set(names) name1 = 'bob' for i in name_set: if name1.lower() == i: print(True) else: print(False)