How to avoid L in Python

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

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

+4
source share
2 answers

L is just for you. (So ​​you know him a long ) And there is nothing to worry about.

 >>> a = sum(range(49999951,50000000)) >>> a 2449998775L >>> print a 2449998775 

As you can see, the print value (actual value) does not have L , only repr (representation) displays L

Consult this post

+5
source

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

If you need to print such a number, L usually will not.

What happens is that the Python interpreter prints the result of repr() in all the return values ​​of the expressions if they do not return None to show you what the expression is. Use print if you want to see the result of a string:

 >>> sum(range(49999951,50000000)) 2449998775L >>> print sum(range(49999951,50000000)) 2449998775 
+7
source

Source: https://habr.com/ru/post/1489747/


All Articles