red_balls=[]
blue_balls=[]
zx=[[6,33,"红球",red_balls],[1,16,"蓝球",blue_balls]]
for item in zx:
print(f"开始选择{item[2].center(50,'-')}")
count=0
while count<item[0]:
choice=input(f"输入第{count+1}个{item[2]}:")
if not choice.isdigit():
print("不合法")
continue
choice=int(choice)
if 0<choice<item[1] and choice not in item[3]:#合法的球
item[3].append(choice)#动态的往每个球色的列表里加球。。。
count+=1
print(red_balls,blue_balls)
运行结果如下: