Hi,

I wrote a simple program, as follows-
def finddivisor(n1, n2):
    divisor = ()
    
    for i in range(1, min(n1+n2)+1):
        if n1%i == 0 and n2%i==0:
            divisor = divisor + (i, )
    return divisor

n1 = eval(input('Enter first number: '))
n2 = eval(input('Enter second number: '))


divisors= finddivisor(n1,n2)
print (divisors)

However, when I run it, the message

Traceback (most recent call last):
  File "C:/Python33/Trials/tuple trial.py", line 21, in <module>
    divisors= finddivisor(n1,n2)
  File "C:/Python33/Trials/tuple trial.py", line 12, in finddivisor
    for i in range(1, min(n1+n2)+1):
TypeError: 'int' object is not iterable

shows up. Could you please tell me where I went wrong? Does it mean that if i 
in an integer, it will not be iterated? But isn't the code for i in range(1, n) 
a very frequently used line?

Thank you for your help!
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to