-2

How can I remove whitespaces (multiple spaces, tab, nextline) from the input code in Python programming? For example,

input = "p y t h o n e x e r c i s e s"

or

input = "python exercises"

or

input = "python exercises\n"

I want to show just a single word. That means the output will be "pythonexerecises" How can I solve this problem using python?

Pranav Hosangadi
  • 17,542
  • 5
  • 40
  • 65
  • Please retake the [tour], and read [ask] and [what's on-topic here](/help/on-topic). [Asking on Stack Overflow is not a substitute for doing your own research.](//meta.stackoverflow.com/a/261593/843953) Also, _"Implement this feature for me"_ is off-topic. Make an _honest attempt_ and ask a _specific_ question if you get stuck. – Pranav Hosangadi Oct 16 '20 at 17:32

1 Answers1

1
inp = "p y t h o n e x e r c i s e s"
out = ''.join(inp.split())
print(out)
Divyessh
  • 1,774
  • 1
  • 3
  • 21