I tried it on here but it can not print the long numbers like this
for i in range(1,222222222222222):
print i
Error:
Traceback (most recent call last):
File "x.py", line 1, in <module>
for i in range(1,222222222222222):
MemoryError
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use xrange instead of range.
range generates a list, stores it in the memory and performs the loop on each item. This generates memory errors when dealing with quite big numbers.
xrange is a generator not a list, items are created on the fly, so it does not harm for the memory
I hope this helps