[Tutor] for loop for long numbers
breamoreboy at yahoo.co.uk
Mon Aug 3 23:02:40 CEST 2015
On 03/08/2015 19:15, Dima Kulik wrote:
> Hi to all.
> Can you help me plz.
> 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?
You cannot do anything about it directly with Python 2 but this works
fine on Python 3. Work arounds from
range = lambda stop: iter(itertools.count().next, stop)
i = 0
while i < stop:
i += 1
Having said that what are you trying to achieve? If you tell us we may
be able to suggest a cleaner solution.
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
More information about the Tutor