Convert string to respective data type ie. int or long (python3)

Prashant Singh picture Prashant Singh · Jul 28, 2017 · Viewed 9.1k times · Source
temp=input()
l=list(map(int,temp.split()))
count=0
for i in range (1,min(l[0],l[1])+1):
    if l[0]%i==0 and l[1]%i==0:
        count+=1
print (count)

Above code takes 2 or more numbers and finds count of common factors. the range for these numbers is 1 to 10**12.

How to handle both int and long data types in this code? Kindly help.

Answer

Qeek picture Qeek · Jul 28, 2017

As opposed to Python 2, Python 3 doesn't distinguish between int and long (long is gone from Python 3). It's just an integer which can be even longer than 64-bit.

From Python 3 documentation

Integers have unlimited precision.