0

I have a problem. My code:

a = '0.00003162'
b = float(a)
print(b)

result: 3.162e-05

I want operating on 0.00003162.


list = ['0.00003162', '0.00003161', '0.00003160', '0.00003159', '0.00003158']
list2 = [float(i) for i in list]

result: [3.17e-05, 3.171e-05, 3.172e-05, 3.187e-05, 3.188e-05]

but i want: [0.00003162, 0.00003161, 0.00003160, 0.00003159, 0.00003158]

wjandrea
  • 28,235
  • 9
  • 60
  • 81
  • 3
    Does this answer your question? [How do I suppress scientific notation in Python?](https://stackoverflow.com/questions/658763/how-do-i-suppress-scientific-notation-in-python) – Joshua Varghese Apr 12 '20 at 17:11
  • 5
    You seem to be confusing floats and their string representations. If you want to control the strings used to print them, use formatting. In any event, unless this is for some end user -- why not just accept the defaults? It isn't a bad idea to become comfortable with scientific notation. – John Coleman Apr 12 '20 at 17:11
  • 1
    To add to my previous comment `3.162e-05 == 0.00003162` evaluates to `True` so you *are* getting the floats that you want but are just unhappy with the way `print()` prints them by default. – John Coleman Apr 12 '20 at 17:19

0 Answers0