인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

canflight0080096's profile image
canflight0080096

asked

Introduction to Python Algorithm Problem Solving (Coding Test Preparation)

4. Subsets with the same sum (DFS)

break 랑 return 이랑 차이가 무엇인가요?

Written on

·

1.2K

0

이전에는 종료를 할때 break 를 쓰셨는데

함수에서 하실 때는 return 으로 쓰시는 이유가 무엇인가요?

답변주시면 감사하겠습니다!

python코테 준비 같이 해요!

Answer 1

0

codingcamp님의 프로필 이미지
codingcamp
Instructor

안녕하세요^^

단순 반복문(for문, while문)을 멈추고 싶을 때 break를 쓰고 호출된 재귀함수를 종료하고 싶을 때 return으로 종료합니다. return은 값을 반환하는 명령어 이기도 하지만 함수를 종료하는 명령어이기도 합니다.

주말임에도 불구하고 답변해주셔서 감사합니다!

canflight0080096's profile image
canflight0080096

asked

Ask a question