# 小白请教python

0
[已解决问题] 解决于 2023-10-24 22:09

def has_duplicates(nums):
for num in nums:
if nums.count(num) > 1:
return True
return False

# 测试

numbers = ['1000223453', '1000227458', '10002235539', '100022343356', '1000227458', '1000223423','1000223412','1000223498']
print(has_duplicates(numbers)) # 输出：True
c=[n for n in numbers if numbers.count(n) > 1]
list2=list(set(c))
print('单据号',list2)

True

0

has_duplicates=lambda iter_var:True if len(set(iter_var))==len(iter_var) else False

DidierFeng | 菜鸟二级 |园豆：221 | 2023-10-11 11:05

def find_duplicates(arr):
seen = set()
duplicates = []
for num in arr:
if num in seen:
duplicates.append(num)
return duplicates

# 改好了

0

has_duplicates()函数没值

Adventur | 园豆：202 (菜鸟二级) | 2023-10-10 18:08

def has_duplicates(*nums):
n = []
for num in nums:
if nums.count(num) > 1:
n.appenf(num)
return True,list2
list2 = list(set(n))
return False,list2

# 测试

numbers = ['1000223453', '1000227458', '10002235539', '100022343356', '1000227458','1000227458', '1000223423','1000223412','1000223498']
print(has_duplicates(numbers)) # 重复数据输出不出来

您需要登录以后才能回答，未注册用户请先注册