title: "TypeError: list indices must be integers or slices, not str"
body: <p>Trying to complete a data analysis homework asignment, but constantly getting the same error despite several attempts</p>
  <p>Some help would be greatly appreciated. The following is my code:</p>
  <pre><code>def is_valid_duration(duration_as_string):
       try:
           duration = str(duration_as_string)
       except ValueError:
           return False
       else:
           duration = duration.strip(&quot;''&quot;)
           duration = duration.strip(&quot;`&quot;)
           return float(duration) &gt; 10
  
  filepath = &quot;ufo-sightings.csv&quot;
  
  
  sightings_us = [row for row in ufosightings_count if row[&quot;country&quot;] == &quot;us&quot; ]
  fball = [row for row in sightings_us if (is_valid_duration(row[&quot;duration (seconds)&quot;])) and (row[&quot;shape&quot;] == &quot;fireball&quot;)]
  
  print(fball[&quot;datetime&quot;], fball[&quot;state&quot;])
  </code></pre>
  <p>The error I'm getting is this:</p>
  <pre><code>TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-80-652c5f3a77d7&gt; in &lt;module&gt;
       28 fball = [row for row in sightings_us if (is_valid_duration(row[&quot;duration (seconds)&quot;])) and (row[&quot;shape&quot;] == &quot;fireball&quot;)]
       29 
  ---&gt; 30 print(fball[&quot;datetime&quot;])
  
  TypeError: list indices must be integers or slices, not str
  </code></pre>