From 8e72f0ee5575a546659e72bdc3c27ef4929a4792 Mon Sep 17 00:00:00 2001 From: "DESKTOP-P0AV9A2\\dddddd" Date: Mon, 23 Nov 2020 15:23:50 +0900 Subject: [PATCH] app.py pull request --- app.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) 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