双色球的Python实现

代码如下:

red_ball = []
blue_ball = []
count = 0
while count < 6:
    n = int(input('\033[31mPlease enter the red ball of your choice(1-32):\033[0m'))
    if 0 < n < 33:
        if n in red_ball:
            print('the number is already in the list,please choose another number~')
        else:
            red_ball.append(n)
            count += 1
            print('\033[31m',[count],'red ball:%d\033[0m'% n)
    else:
        print('Please ensure your number between 1 and 32~')
while count < 8:
    n = int(input('Please enter the blue ball of your choice:'))
    if 0 < n < 17:
        if n in blue_ball:
            print('the number is already in the list,please chooose another number~')
        else:
            blue_ball.append(n)
            count += 1
            print([count],'blue ball:%d'% n)
    else:
        print('Please make sure your number is between 1 and 16~')
else:
    print(' red ball :',red_ball,'\n\r','blue ball:',blue_ball)

效果如下:


image.png

image.png

你可能感兴趣的:(双色球的Python实现)