Search code examples
pythonpython-3.xinputstripwords

How to give input permission to accept a name with a space?


I know that in Python, in order for the program to ignore space you can use input("something").strip() but what function do you use for the program to ignore the space if it's in the middle of the word like ja ck, also is there a way to combine the name, so if you enter it like ja ck it will print jack?


Solution

  • Replace the spaces with blank

    >>> input("something\n").replace(' ','')
    something
    ja       ck
    'jack'