[Python] 백준 2753번 - 윤년
Python의 and/or 조건식을 사용해 윤년 판별 조건을 구현한 풀이를 정리했습니다.
For the English version of this post, see here.
[Python] 백준 2753번 - 윤년
풀이
1
2
3
4
5
6
7
8
year = int(input())
if year%4 == 0:
if (year%100 != 0) or (year%400 == 0):
print("1")
else:
print("0")
else: print("0")
Python에서는 Java나 C와 달리, ||나 && 연산자를 or과 and로 사용해야한다.