[Python] 파이썬 기초5. 조건문
자바스크립트와 달리 is, is not 을 추가로 사용할 수 있다. 그리고 else if 대신 elif를 사용한다. #조건문 def plus(a,b): if type(b) is str: return 'type is str' else: return a+b def plus(a,b): if type(b) is int or type(b) is float: return a+b else: return None print(plus(12,1.2)) print(plus(12,'10')) #2. def age_check(age) : print(f'you are {age}') if age < 18: print('you cant drink') else: print('enjoy your drink') age_check(18) ..
Python
2021. 12. 31. 16:24