[Python] Remove all line breaks from a long string of text

Discussão em 'Python' iniciado por Stack, Julho 6, 2025.

  1. Stack

    Stack Membro Participativo

    Basically, I'm asking the user to input a string of text into the console, but the string is very long and includes many line breaks. How would I take the user's string and delete all line breaks to make it a single line of text. My method for acquiring the string is very simple.

    string = raw_input("Please enter string: ")


    Is there a different way I should be grabbing the string from the user? I'm running Python 2.7.4 on a Mac.

    P.S. Clearly I'm a noob, so even if a solution isn't the most efficient, the one that uses the most simple syntax would be appreciated.

    Continue reading...

Compartilhe esta Página