Recursion
-
Recursive FunctionComputer Science/Basic Programming with Python 2021. 11. 19. 20:02
함수내부에서 자기 자신을 부르는 식으로 코딩을 하는 방법이 있는데, 바로 Recursive function이다. def function(count): if count > 0: print(count, 'now') function(count - 1) print('result:', count) 위와같이 function안에 function을 불러서 다른 조건으로 처리하는식으로 코딩할 수 있다. 만약 5를 집어넣으면 function(5) 5 now 4 now 3 now 2 now 1 now result: 0 result: 1 result: 2 result: 3 result: 4 result: 5 loop을 쓰는것과 마찬가지로 어떤 동작을 반복적으로 하는것인데, 이러한 recurisve function을 쓸 때 주..