강의

멘토링

로드맵

Inflearn Community Q&A

No author

This post's author information has been deleted.

Getting Started with Programming: Introduction to Python (Inflearn Original)

functions(1-1): Functions are important in programming.

로또 추첨기

Written on

·

177

0

수업 듣다가 set은 랜덤으로 뽑아 올 수 있다고 하길래, 로또추첨기가 떠올라서 해봤습니다. 

이거 말고 def를 이용한 것은 어떻게 해야 될 지 감이 잘 안옵니다ㅠㅠ

 

항상 답변 감사드립니다!

 

a = {1, 3, 7, 9, 35, 65, 79, 94, 73, 92}
while a:
    print(a.pop())
    if len(a) < 4:
        print("Congratulations")
        break
python

Answer 1

0

안녕하세요.

 

def를 이용한 것은 아래와 같이 작성해주시면 됩니다.

참고해서 연습해보시길 바랍니다 :)

 

def lotto(a):

    while a:

        print(a.pop())

        if len(a) < 4:

            print("Congratulations")

            break

 

val = {1, 3, 7, 9, 35, 65, 79, 94, 73, 92}

 

lotto(val)

 

궁금한 점이 있으면 또 질문주세요.

감사합니다.

No author

This post's author information has been deleted.

Ask a question