Steve T
last year
Stevecountry asked

In Python, how do I find the remainder when dividing numbers?

Abhay Jajodia
Expert
last year
Abhay Jajodia answered

Hi Steve,

Use the modulo operator %. It gives the remainder after division.

Example:

print(14 % 3)  # 2

So 14 % 3 is 2, because 14 divided by 3 leaves 2 leftover.

If you have more questions, I am here to help 😊

Python
This question was asked as part of the Getting started with Python course.