-4

Why isn't it possible to strip the decimal point off of a float?

str(1.5).strip(".") returns 1.5

Why doesn't it return 15?

Has the decimal point an own symbol that is not equal with the full stop .?

Thomas
  • 507
  • 5
  • 15

1 Answers1

4

str.strip() only removes characters at the beginning and end, not in the middle. It's mostly used for removing extraneous whitespace around a line of input (with no argument, it defaults to removing whitespace).

Use str.replace() to replace a string anywhere:

str(1.5).replace('.', '')
Barmar
  • 741,623
  • 53
  • 500
  • 612