-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
  • 23,755
  • 7
  • 44
  • 70

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
  • 2,540
  • 1
  • 7
  • 24