title: Python string index
body: <p>I have a file which contains users:</p>
  
  <pre><code>Sep 15 04:34:31 li146-252 sshd[13326]: Failed password for invalid user ronda from 212.58.111.170 port 42579 ssh2
  Sep 15 04:34:33 li146-252 sshd[13328]: Failed password for invalid user romero from 212.58.111.170 port 42715 ssh2
  Sep 15 04:34:36 li146-252 sshd[13330]: Failed password for invalid user rom from 212.58.111.170 port 42838 ssh2
  </code></pre>
  
  <p>Trying to use index method for string to print the users from the file, which is not working:</p>
  
  <pre><code>with open ('test.txt') as file: 
          for line in file.readlines(): 
                  lines = line.split() 
                  string = ' '.join(lines)
                  print string.index('user')+1
  </code></pre>