双色球的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)

效果如下:

 

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM