根据用户输入的数字,形成一组双色球号码

# 双色球 6个红球(1-33 1个蓝球(1-16

red_balls = []
blue_balls = []
rules = [
[6, 33, '红球', red_balls],
[1, 16, '蓝球', blue_balls]
]

for rule in rules:
print(f'开始选择{rule[2]}'.center(50, '-'))
count = 0
while count < rule[0]:
choice = input(f'选择第{count + 1}个{rule[2]}: ').strip()
if not choice.isdigit():
print('非法输入')
continue
choice = int(choice)
if 0 < choice <= rule[1] and choice not in rule[3]:
rule[3].append(choice)
count += 1
print(red_balls, blue_balls)

类似文章