def plus(a, b):
if type(b) is int or type(b) is float:
return a + b
elif type(b) is str:
print("dont put here str")
else:
return None
print(plus(12, "10"))
결과 값 :
dont put here str
None
소괄호 로 묶지 않고 위 처럼
if - elif - else 조건문 :
를 사용하면 된다.
'Python' 카테고리의 다른 글
Python [for in] (0) | 2019.11.24 |
---|---|
Python [논리 연산자 and, or, not] (0) | 2019.11.24 |
Python [format] 스트링 안에 변수 값 넣고 출력 (0) | 2019.11.24 |
Python [function] arg 위치 지정 호출 (0) | 2019.11.24 |
Python [function] return , void 차이 (0) | 2019.11.24 |