0

this is my first post to Stack Overflow. I have used it many times before but this is the first error that I have not found a solution to thus far. I am having a problem with a Python script where when I am changing an element in a list, the item replacing the element in the list drops the scientific notation aspect (i.e. E+08). Here is a snippet of the code and terminal output that is very strange to me. Thanks in advance for all help!

for i in range(0, len(EinsteinCof)):
    for j in range(0, len(finalindexing)):
        if i == finalindexing[j][0]:
            if len(finalindexing[j]) == 3:
                EinsteinFinal = float(EinsteinCof[finalindexing[j][0]]) + float(EinsteinCof[finalindexing[j][1]]) + float(EinsteinCof[finalindexing[j][2]])
                print str(EinsteinFinal)
                EinsteinCof[finalindexing[j][0]] = str(EinsteinFinal)
                print str(EinsteinCof[finalindexing[j][0]])

Terminal Output:

4.1079763384e+13
4.1079763384    # <-- Where did e+13 go? 
2269472400.0
2269472400.0
3.1777892e+12
3.1777892e+1 # <--where did e+12 go?
9.062911e+11
9.062911e+11
Simon MᶜKenzie
  • 8,344
  • 13
  • 50
  • 77
  • What happens if you print `EinsteinCof[finalindexing[j][0]]` instead? As an aside, why are you storing all your numbers as strings then parsing them each time? I suspect that you should only be using `str` when rendering data for output. – Simon MᶜKenzie Apr 02 '15 at 03:17
  • What kind of object is `EinsteinCof`? It looks like it might be a container of fixed-length strings, which is a problem since the fixed length appears to be too short for some of your number's string representations. – Blckknght Apr 02 '15 at 03:41

0 Answers0