title: Having trouble with except function/ input validation
body: <p>I am working on some code for a homework assignment where I have to take the numbers in a the file, calculate the sum of them all, the average and how many lines there are. This is what I've come up with so far</p>
  <pre><code>invalidEntry= True
  </code></pre>
  <p>#Input validation</p>
  <p>while (invalidEntry) :</p>
  <pre><code>try:
      
      total = 0
      lines = 0
      
      Validate= input(&quot;Please enter the name of the text file. : &quot;)
      if Validate ==(&quot;Random.txt&quot;) :
          red= open( 'Random.txt', 'r')
          for count in red:
              strip = line.strip(&quot;\n&quot;)
              lines += 1
              average = total/200
              total = total + int(count)
              
              print(&quot;The number of lines is : &quot;,lines)
              print (&quot;The total sum is : &quot; ,total)
              print(&quot;The average is :&quot; , average
      invalidEntry= False
      
      except:
          print(&quot;This isn't a valid file!&quot;)
  </code></pre>
  <p>I keep getting a syntax error for the except function and I'm unsure if I have the input validation set up properly. Any help would be appreciated.</p>