crac

导航

no.4 抽奖测试

#-*-coding=gbk-*-
import sys
import random
a=[]
try:
    for x in range(1,20+1,1): #打印20人数编号
        a.append(x)
    i=0
    key=raw_input("请输入a,开始抽奖号码:")
    while (key=="a"):
        b=random.choice (a)
        #b=str(b)
        i+=1
        print "     第%d个中奖号: %s"% (int(i),b)
        a.remove(b)
        key2=raw_input("请输入a,开始抽奖号码:")

    else:
        print ('ERROR!!')
except IndexError as e:
    print "已经抽完!"
    

 

posted on 2016-05-09 15:46  crac  阅读(136)  评论(0编辑  收藏  举报