1

I am a beginner in phyton and would like to ask someone to look at my code, I just can't figure out what is wrong with it.

num1 = input("Please give me a number")
num2 = input("Please provide the other number")
min = min(num1,num2)
maxDivisor = 0

for x in range(1, min+1):
    if (int(num1) % x == 0) and (int(num2) % x ==0):
        maxDivisor = x
print("This is the biggest common divisor: " + str(maxDivisor))
D.Tomi
  • 71
  • 4
  • 1
    What's the error message? – Sociopath Oct 14 '19 at 11:39
  • 1
    `input` returns a string, your `min` doesn't make much sense because of it. Do `num1 = int(input(...))` – h4z3 Oct 14 '19 at 11:41
  • @h4z3 well its depends on python version – Reznik Oct 14 '19 at 11:42
  • @Reznik What depends? Input returns a string. `min` on strings will return a string... or not work at all - either way it *doesn't make much sense* (<-that's exactly what I wrote, not that it will break for sure, just that it doesn't make sense) for the code. – h4z3 Oct 14 '19 at 11:46
  • @h4z3 because you dont know the python version, input can evaluate the input into integer, in python2, which can point out there is another problem – Reznik Oct 14 '19 at 11:47
  • @Reznik 1. OP used Python3 syntax. 2. OP did explicit `int` conversion in `if` below. So it was safe to assume it's Python3, and just that OP's `int` conversion is done too late. – h4z3 Oct 14 '19 at 13:05
  • Thank you guys! I indeed use Python 3, and I could solve the problem by parsing my input to int! Thanks! – D.Tomi Oct 14 '19 at 18:30

0 Answers0