mercredi 14 février 2018

Python3.x Checking Lotto Number

I generated random numbers for lotto and if ticket matches with it, the program says how he/she win. For example it might be you guess 5 digits in a true squence or 4 digits. Maybe you got amorti... (ticket numbers must be contain 7-digit number). But something is wrong here, the code working but never give the result

import random
def main(ticket):
    winner_numbers = [random.randint(1000000,9999999)]
    six_numbers = [random.randint(100000,999999) for i in range(2)]
    five_numbers = [random.randint(10000,99999) for i in range(3)]
    four_numbers = [random.randint(1000,9999) for i in range(5)]

    amorties = [random.randint(0,0)  for i in range(2) ]
    keep_going = True
    while keep_going:
        if amorties[0]==amorties[1]:
            keep_going = True
        else:
            keep_going = False

    big_list = str([winner_numbers,six_numbers,five_numbers,four_numbers,amorties])
    ticket = str(ticket)
    print(big_list)

    if big_list[0] ==ticket:
        print("BIG PRIZE!!!")
    elif str(big_list[1][0]) == str(ticket)[1:] or str(big_list[1][1]) == str(ticket)[1:]:
        print("win 6 digits")

    elif big_list[2][0] == ticket[2:] or big_list[2][1] == ticket[2:] or big_list[1][0] == ticket[2:]:
        print("win 5 digits")

    elif big_list[3][0] ==ticket[3:] or big_list[3][1]==ticket[3:] or  big_list[3][2] == ticket[3:] or big_list[3][3]== ticket[3:] or big_list[3][4] == ticket[3:]:
        print("WIN-4 digits")

    elif big_list[4][0] == ticket[-1] or big_list[4][1] == ticket[-1]:
        print("Amorti")
    else:
        print("Keep Trying...")

main(1234567)




Aucun commentaire:

Enregistrer un commentaire