4

I need to take a 6-significant-digit number and make it a 3-significant-digit number, but the string is structures as this:

string1 = 1.00466E+15

and I need

string2 = 1.00E+15

How do I cut out the 5th, 6th, and 7th character from this string?

  • possible duplicate of [How to delete a character from a string using python?](http://stackoverflow.com/questions/3559559/how-to-delete-a-character-from-a-string-using-python) – Air Nov 26 '14 at 23:11
  • Did the answer below solve your problem? If not, what other issues are you having? – Patrick White Nov 28 '14 at 13:27

1 Answers1

2

string2 = string1[:4] + string1[7:]

See: https://docs.python.org/3/tutorial/introduction.html#strings - specifically 'slicing'

Patrick White
  • 671
  • 5
  • 19