PROBLEM 8
Easy

Last Digit

Programming Basics · Python

</>
STATUS Not solved

TASK

Problem

#8

Given a non-negative integer `n`, print its last digit.

EXAMPLE

Example

Input
4827
Output
7

LIMITS

Constraints

Quantities, prices, and balances are integers from 0 to 10^9; other integer inputs have absolute value at most 10^9.
📖
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 returns the remainder after division. `print()` displays the program result. Print only what the problem statement requires.

**Connection to this task.** The `%` operator returns a division remainder. Therefore `n % k` is useful for divisibility checks and for working with the last digits of a number. The expression `n % 10` shows how this idea is applied to the task data.

💡
NEED HELP? Hints
+

['The last digit is the remainder after division by 10.']

ANSWER Solution
+
n = int(input())
result = n % 10
print(result)