Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Converting a list of integers into a single integer

Hi,

So here's what I have to convert an interger into a list of integers. pie = pi.n(digits = 10) pies = list(pie.str()) pies.remove('.') pies = [int(i) for i in pies]

output: [3,1,4,1,5,9,2,6,5,3]

So after manipulating this list of integers I would like to then reverse the process to create a new integer. The only way I can think of is to take each item, and multiply them by the factor. ie. zero term wouldn't need to be multiplied, but the first term in list would be multiplied by 0.1, second would be multiplied by 0.01, and then add them all up. Is there an easier way of converting back to an integer?