title: How can I get rid of certain characters to the end of each line in a list?
body: <p>I currently have code which pulls from a file called output.txt. It reads through these lines and puts them in a list. If the word "Success" is found, it prints that line out. Currently it prints out the whole line. I want to be able to grab the first part of each line for my next task but I am having issues with getting rid of the rest of the line after a certain character. </p>
  
  <p>For example the lines print:</p>
  
  <pre><code>user:pass Success Info
  user:pass Success Info
  </code></pre>
  
  <p>etc..</p>
  
  <p>I would like to just have it return:</p>
  
  <pre><code>user:pass
  user:pass
  user:pass
  </code></pre>
  
  <p>I am fairly new to python so I am struggling a bit with how to get rid of the rest of the line</p>
  
  <p>I have tried splitting from the word Success on but that is not working right. </p>
  
  <pre><code>lines = []
  with open("output.txt", "r") as f:
      for line in f.readlines():
          if 'Success' in line:
              lines.append(line.rstrip('\n'))
  for element in lines:
      print(element)
  </code></pre>
  
  <p>It currently prints <code>user:pass Success Info</code></p>
  
  <p>The actual output I want is <code>user:pass</code></p>
  
  <p>I am open to any suggestions</p>