用户:
6212377查看:14 回复:9 评论:14 创建时间:2022-07-29T12:34:53
本人急找一python大佬 刚刚开始学python,很多问题不懂,现公开寻找python大佬 要求每天至少5小时在线 可以咨询问题
6212377import random
x = []
y = []
xx = 0
yy = 1
xxx = 0
yyy = 0
for count in range(100):
x.insert(1, random.randint(1, 10))
y.insert(1, random.randint(1, 10))
for count in range(100):
xx += 1
for count in range(len(y)):
xxx = x[xx]
yyy = y[yy]
if(xxx == yyy):
del x[xx]
del y[yy]
print(xx)
yy += 1
报错,帮我解决一下
点赞0
评论
你要的代码,帮你把bug修了
import random
list_a = []
list_b = []
for i in range(10):
list_a.append(random.randint(1,10))
list_b.append(random.randint(1,10))
print(list_a,'\n',list_b,'\n')
inter = set(list_a).intersection(set(list_b))
print(inter)
#以下内容好像是有个函数可以解决但是我忘了
for i in inter:
na = list_a.count(i)
nb = list_b.count(i)
if na > nb:
for k in range(nb):
del list_a[list_a.index(i)]
del list_b[list_b.index(i)]
else:
for k in range(na):
del list_a[list_a.index(i)]
del list_b[list_b.index(i)]
print(list_a,'\n',list_b)点赞0
评论