[Tutor] for loop for long numbers

Peter Otten __peter__ at web.de
Tue Aug 4 08:17:19 CEST 2015

Dima Kulik wrote:

> I want to make a for loop with a huge numbers.
> for example:
> for i in range (0,9000000000):

> but range and xrange cant operate with such big numbers.
> Can some on help me?

If you are just beginning with Python and do not require any libraries that 
are only available for Python 2 the obvious solution is to switch to Python 

But note that if some_code() takes 1 microsecond the loop will run for about

>>> 9000000000/60/60/24/1000

104 days. Did you take that into consideration? What are you trying to 
achieve? If you explain what you want to do with your script one of us may 
be able to come up with a better way to tackle your problem.

More information about the Tutor mailing list