'Prompt the user to input 2 positive integers using while loop then print their greatest common divisor - Python
I would like the user to input two positive integers at runtime and the while loop to read the input and store it as a variable to them calculate the greatest common divisor using math lib. I've
from math import gcd
from sys import argv
count = 0
while count < 2:
count +=1
num = int(input("Enter 2 numbers"))
result = gcd(int(argv[1]), int(argv[2]))
print(result)
ValueError: invalid literal for int() with base 10: '--ip=127.0.0.1'
Input at runtime: 16, 28 Expected Output: 4
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|