diff --git a/README.md b/README.md deleted file mode 100644 index d27672e..0000000 --- a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# python-lotto-app - -이건 로또 앱이에요! 로또번호 생성기에요 diff --git a/app.py b/app.py index 92832af..6b94f70 100644 --- a/app.py +++ b/app.py @@ -20,7 +20,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