title: ValueError: substring not found, What am I doing wrong?
body: <pre><code>def get_file():
    lst_Filename = []
    while True:
      Filename = input('\nPlease enter name of ballot file: ')
      try:    
          read_Filename = open(Filename, 'r')
          txt_Filename = read_Filename.readlines()
          lst_Filename = [word.strip() for word in txt_Filename]
          read_Filename.close()
          return lst_Filename
      except IOError:
          print(&quot;The file&quot;,Filename,&quot;does not exist.&quot;)
          continue
  
  
  lst_Filename = get_file()
  lst2 = {}
  for item in lst_Filename:
      if item.index('1') == 0:
          print(item)
  </code></pre>
  <p>The lst_Filename is structured as follows: ['1490 2 Mo', '1267 3 Mo', '2239 6 Mo', '1449 7 Ks'], the actual file contains hundreds of items in the list.</p>
  <p>I am trying to select the item that begins with '1'. When I run the program, the first two items is printed</p>
  <pre><code>1490 2 Mo
  
  1267 3 Mo
  </code></pre>
  <p>then I get the ValueError: substring not found, it says the problem is with the line &quot;if item.index('1') == 0:&quot;, i assume because '2239 6 Mo' does not begin with '1'</p>
  <p>What I don't understand is that my codes says for every item in the lst_Filename, if that item(which is a string) has the substring '1' in its 0 index then select the item.</p>
  <p>Isn't the 'if' a selection statement, why doesn't the program skips through items that don't begin with '1'.</p>