Entering a very large number

Wolfgang Maier wolfgang.maier at biologie.uni-freiburg.de
Fri Mar 23 08:30:11 EDT 2018


On 03/23/2018 01:16 PM, ast wrote:
> Hi
> 
> I found this way to put a large number in
> a variable.
> 
> C = int(
> "28871482380507712126714295971303939919776094592797"
> "22700926516024197432303799152733116328983144639225"
> "94197780311092934965557841894944174093380561511397"
> "99994215424169339729054237110027510420801349667317"
> "55152859226962916775325475044445856101949404200039"
> "90443211677661994962953925045269871932907037356403"
> "22737012784538991261203092448414947289768854060249"
> "76768122077071687938121709811322297802059565867")
> 

A very simple improvement would be to use a single
triple-quoted string. Assuming you are copy/pasting
the number from somewhere that will save a lot of your
time.

> It works but is it not optimal since there is a
> string to int conversion.
> 
> I was not able to put an integer directly because
> character '\' for line cut doesnt work inside an
> integer
> 
> C = \
> 28871482380507712126714295971303939919776094592797\
> 22700926516024197432303799152733116328983144639225\
> ...
> 76768122077071687938121709811322297802059565867
> 
> doesn't work
> 
> Do you have a better idea ?
> 
> Thx
> 
> 




More information about the Python-list mailing list