Python_Default Parameters

Eugenius1st·2022년 12월 17일
0

Python

목록 보기
14/16
post-thumbnail

Default Parameters

파이썬 함수의 인자로
default 를 정해 놓을 수 있다. 그래서

def say_hello(name="anonymous"):
	print("hello", name)
    
say_hello("eugene")
say_hello()

# hello eugene
# hello anonymous

argument가 일치하지 않는 경우에 원래는 error를 뱉지만
default parameter를 설정해 준다면

argument를 전달하지 않더라도
기본으로 설정된 argument로 출력 가능하다.

profile
최강 프론트엔드 개발자가 되고싶은 안유진 입니다

0개의 댓글

관련 채용 정보