본문 바로가기

Python

Python function def , use

<함수 정의>

 

def say_hi():

  print("hi!!")

↑ 들여쓰기를 해야함!!! 없으면 에러 남

 

say_hi() => hi!!

 

<함수 정의 시 들여쓰기 없는 경우>

 

def say_hi():

print("hi!!")

 

say_hi() =>

 

  File "main.py", line 2                  43)    print("hi!!")
        ^IndentationError: expected an indented block

* 들여쓰기 없으면 바로 에러남

 

<함수 사용>

 

say_hi()

 

 

'Python' 카테고리의 다른 글

Python [function] return , void 차이  (0) 2019.11.24
Python [function] argugment use  (0) 2019.11.24
Python Dictionary type (javascript obj 같은 것)  (0) 2019.11.24
Python tuple [Sequence Type]  (0) 2019.11.23
Python list [Sequence type]  (0) 2019.11.23