0

I'm pretty new to programming and currently working on a program in Python where I'm pulling data from an API and storing certain values in a list.

I have the initial list where the values stored. Then I have a while loop that pulls data from the API every X minutes that I store in a new list.

I want to compare the initial list with the new list to check if a new value has entered the list. Both lists always contain 7 values and It's also possible that multiple new values have entered the list (meaning multiple other left the list)

The end result should give something like "value X & y have just entered the list" however I don't want it to print this when a value has just changed places while it was already in the initial list.

How would I go about doing this?

Jesse
  • 1
  • 2
    Use [sets](https://docs.python.org/3/c-api/set.html) `set(list_2)-set(list_1)` gives you the new members of list_2. – dawg Dec 12 '20 at 02:04
  • I'd prolly make the lists into sets (uniqueness of entry enforced). Then you get a whole lot of nice ways to deal with your question (is element, difference etc). – roadrunner66 Dec 12 '20 at 02:04

0 Answers0