title: Detecting and Printing Streaks
body: <p>I wrote up a bit of code to detect streaks in data and am just wondering why it's not working.</p>
  
  <p>I've got a sequence of -1s, 0s and 1s. I'd like to report on where the nonzero values are. But they tend to come in streaks; so rather than just reporting individual locations, I'd like to report streaks. Here is a simple example:</p>
  
  <pre><code>sequence=[-1,-1,0,0,1,1]
  
  print('Negative Influences:')
  streaking=False
  streak=[]
  for j in range(len(sequence)):
      if streaking==False and sequence[j]==-1:
          streaking==True
          streak.append(j)
      elif streaking==True and sequence[j]==-1:
          streak.append(j)
      elif streaking==True and sequence[j]!=-1:
          streaking==False
          print(streak)
          streak=[]
  
  print('Positive Influences:')
  streaking=False
  streak=[]
  for j in range(len(sequence)):
      if streaking==False and sequence[j]==1:
          streaking==True
          streak.append(j)
      elif streaking==True and sequence[j]==1:
          streak.append(j)
      elif streaking==True and sequence[j]!=1:
          streaking==False
          print(streak)
          streak=[]
  </code></pre>
  
  <p>I'd expect the following output:</p>
  
  <pre><code>Negative Influences: [0,1]
  Positive Influences: [4,5]
  </code></pre>
  
  <p>Unfortunately, I get blanks:</p>
  
  <pre><code>Negative Influences:
  Positive Influences:
  </code></pre>
  
  <p>To debug, I tried adding a print(streaking) command at the end of each iteration. It revealed that streaking is always False. Why is that? streaking is supposed to become True when it hits the first -1 (or 1, respectively).</p>
  
  <p>Thanks</p>