# Get the Last Digit of Number in Python Tutorial Example

19-Jun-2023

. Hi Dev,

Now, let's see the post of get the last digit of the number in the Python tutorial example. This article goes into detail on python to get the last digit of a number. I explained simply how to get the last digit of a number in python. We will look at an example of a program to find the last digit of a number in Python. Here, Creating a basic example of the last digit of a number in Python.

There are several ways to get the last digit of a number in Python. I will give you two simple examples to get the last digit from a number. You can see both examples one by one.

Example 1:

main.py

```number1 = 3456

# Get Last Digit from Number
lastDigit = str(number1)[-1]
lastDigit = int(lastDigit)

print(lastDigit)
```

Output:

```6
```

Example 2:

You can get the last digit of a number in Python using the modulus operator (%). Here's an example code:

In this example, the modulus operator % returns the remainder of the division of num by 10, which is the last digit of num.

main.py

```number = 659

# Get last Digit from Number
lastDigit = num % 10

print(lastDigit)
```

Output:

```9
```

#Python