2024-06-07 05:18:23 发布
网友
如何防止在空列表中多次输入相同的值?你知道吗
错误示例
a = [ ] while a [ 4 ] ! = None: #ensure in put 5 times option = input() if option in a: #prevent input same value continue else: a.append(option)
而且,如果我用dict更好?你知道吗
我不是英国人
如果您想拥有唯一的元素集合,应该使用set。你知道吗
set
a = set() while len(a) < 5: a.add(input())
如果您想拥有唯一的元素集合,应该使用
set
。你知道吗相关问题 更多 >
编程相关推荐