Python long integer input
13,696
n = int(raw_input())
This will convert the input to an integer. Since Python employs arbitrary precision arithmetic, we don't have to worry about how big the number is.
>>> n = int(raw_input())
100000000000000
>>> n
100000000000000L
Author by
Vishal Anand
Updated on June 12, 2022Comments
-
Vishal Anand almost 2 years
How can one take a "long int" input in Python 2.7?
P.S. I tried various variations of
n=(*(raw_input()))
but to no avail. -
Maciej Gol over 10 yearsThere is
long
type in Python, but it's different fromlong
of C standard and similar - it has arbitrary precision, and anyint
object beyond int precision becomeslong
.>>> type(int(10000000000)) == long; True
-
thefourtheye over 10 years@kroolik Thanks :) Removed that from the answer.
-
falsetru over 10 years@kroolik, (in Python 2.x).
-
Maciej Gol over 10 years@falsetru, yes. Also, link to the docs (2nd paragraph)