Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid the L in Python

>>> sum(range(49999951,50000000))
  2449998775L

Is there any possible way to avoid the L at the end of number?

like image 626
FZEROX Avatar asked Dec 16 '22 09:12

FZEROX


1 Answers

You are looking at a Python literal representation of the number, which just indicates that it is a python long integer. This is normal. You do not need to worry about that L.

If you need to print such a number, the L will not normally be there.

What happens is that the Python interpreter prints the result of repr() on all return values of expressions, unless they return None, to show you what the expression did. Use print if you want to see the string result instead:

>>> sum(range(49999951,50000000))
2449998775L
>>> print sum(range(49999951,50000000))
2449998775
like image 184
Martijn Pieters Avatar answered Dec 29 '22 22:12

Martijn Pieters