본문 바로가기

Python

Python if - elif - else

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 조건문 :

를 사용하면 된다.