PROBLEM 88
Hard

Number Palindrome

Programming Basics · Python

</>
STATUS Not solved

TASK

Problem

#88

Given a positive four-digit integer, print `YES` if it is a palindrome.

EXAMPLE

Example

Input
1221
Output
YES

LIMITS

Constraints

1000 ≤ n ≤ 9999
📖
LEARN Theory for this problem
+

`input()` reads data entered by the user. The result of `input()` is initially a string. `int()` converts a numeric string into an integer. The `//` operator performs integer division and keeps the whole-number part. The `%` operator returns the remainder after division. Comparison operators `==`, `!=`, `<`, `>`, `<=`, `>=` compare values and produce `True` or `False`. `and` requires all combined conditions to be true. `if` checks a condition and runs its block when the condition is true. `else` runs when the corresponding `if` condition is false. `print()` displays the program result. Print only what the problem statement requires.

**Connection to this task.** The `//` and `%` operators complement each other: the first gives the integer quotient and the second gives the remainder. This is useful when splitting a number into groups or digits. The expression `'YES'` shows how this idea is applied to the task data.

💡
NEED HELP? Hints
+

['Compare first with last and second with third.']

ANSWER Solution
+
n = int(input())
a = n // 1000
b = n // 100 % 10
c = n // 10 % 10
d = n % 10
if a == d and b == c:
    print('YES')
else:
    print('NO')