[Python] ZeroDivisionError: integer modulo by zero [closed]

Discussão em 'Python' iniciado por Stack, Agosto 4, 2025.

  1. Stack

    Stack Membro Participativo

    I was trying to create a simple python code for finding HCF of two numbers using Euclid's method

    a = int(input('Enter the first number: '))
    b = int(input('Enter the second number: '))
    while b != 0:
    rem = int(a) % int(b)
    a = b
    b = rem
    print('The HCF is', a)


    and I got a error like

    Traceback (most recent call last):
    File "C:\Users\PycharmProjects\HCF.py", line 4, in <module>
    rem = int(a) % int(b)
    ~~~~~~~^~~~~~~~
    ZeroDivisionError: integer modulo by zero

    Continue reading...

Compartilhe esta Página