title: How do I make the values I am iterating into a list stop from duplicating the entire list plus one value over and over?
body: <p>The title maybe a bit confusing or if I am not supposed to post here sorry but, I am having trouble with numerical values I am putting into a list continuously with the main objective that I want to plot the values in real time. </p>
  
  <p>My problem is that once the code does the calculations it puts the value in a list and prints the whole list plus the new value. An example would [1] , [1,2],[1,2,3]</p>
  
  <p>How can I prevent this from happening so I can use these values to graph in real time? I believe this is causing me to get the error [KeyError: 'text']</p>
  
  <p>Here is my code: </p>
  
  <pre><code>from tweepy.streaming import StreamListener
  from tweepy import OAuthHandler
  from tweepy import Stream
  import json
  
  import numpy
  
  # Variables that contains the user credentials to access Twitter API
  access_token = ""
  access_token_secret = ""
  consumer_key = ""
  consumer_secret = ""
  
  
  
  #creates empty list
  my_list = [] 
  my_average = []
  my_range = []
  newlist = []
  
  # This is a basic listener that just prints received tweets to stdout.
  class StdOutListener(StreamListener):
  
      def on_data(self, data):
          json_load = json.loads(data)
          texts = json_load['text']
          #print texts
          ***[CALCULATIONS]***
          my_list.append(r)
          #drop zero in list
          if 0 in my_list: my_list.remove(0)
  
  
  
          #calculate average
          average = numpy.mean(my_list)
          x = average[~numpy.isnan(average)]
  
          for i in x:
              if i not in newlist:
                  newlist.append(i)
  
          print newlist       
  
  
  
  
  
  
  auth = OAuthHandler(consumer_key, consumer_secret)
  auth.set_access_token(access_token, access_token_secret)
  stream = Stream(auth, StdOutListener())
  
  # Searches by the keywords
  stream.filter(track=['soil','gardening'],stall_warnings=True)
  </code></pre>
  
  <p>Thank you in advance and hope it makes sense. </p>
  
  <p>P.S any suggestions for plotting the data in real time would be greatly appreciated!</p>