Add a \t at the beginning of each line


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. # Given some text with newlines:
  2. text = "hello\nworld\n!!!"
  3.  
  4. # Add a tab before every newline:
  5. "\t" + text.replace("\n", "\n\t")

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.