diff --git a/app.py b/app.py index 92832af..905b933 100644 --- a/app.py +++ b/app.py @@ -21,6 +21,37 @@ def select_numbers(select_amount:int): lotto = [1,2,3,4,5,6] + ## example 1 + lotto = [] + for i in range(select_amount): + + while True: + select_num = random.randint(1, 45) + + is_duplicated = False + for num in lotto: + if select_num == num: + is_duplicated = True + break + + if is_duplicated: + continue + lotto.append(select_num) + break + + ## example 2 + ''' + candidate_numbers = lotto_numbers[:] + lotto = [] + for i in range(select_amount): + select_num = candidate_numbers.pop(random.randrange(len(candidate_numbers))) + lotto.append(select_num) + ''' + + ## example 3 + ''' + lotto = random.sample(lotto_numbers, select_amount) + ''' return lotto