2022-09-30

python lotto example

import random

def getNum():
    return random.randrange(1,46)
lotto=[]
n=0

while True:
    n=getNum()
    print (n)
    if lotto.count(n)==0:
        lotto.append(n)
    else:
        print("drop duplicated number")
    if len(lotto)>=6:
        break;

#lotto.sort()

for i in range(0,6):
    print("%d " %lotto[i], end="")
 

댓글 없음:

댓글 쓰기