[Solved] look through a very large numbers (1.2e+34) in Python


Python understands 1.2e34, as a float, but you can cast it to an int. int(1.2e34).

If you want to loop between 1 and n inclusive, you would normally use range(1, n+1).

Thus, in Python 3:

for i in range(1, int(1.2e34)+1):
    print(i)   # or do whatever you want

As FHTMitchell pointed out, in Python 2, the value is too large for range or xrange. You could use a while loop instead.

i = 1
while i <= 1.2e34:
    print i    # or do whatever you want
    i += 1

1

solved look through a very large numbers (1.2e+34) in Python