If I have two lists I want to be able to see if the items in one list compare to a different list. For example if I had list1=[1,2,3]
and list2=[2,3,5,1]
I want to be able to see if the numbers in list 2 match list 1 without them being in the same order and even if there are also other numbers. Sort of like in math when you had two sets of numbers and had to get the intersection of them. Is there a way to see if list2 has all the items that are in list1 regardless of order or other numbers? I'm using it for a if command to detect if something is true based on whether the list is equivalent to the other list and then change the variable to "true".
Here's an example of something similar to the bit of code I'm trying to get to work.
listOne=[]
listRight=[1,2,5]
right="false"
while(win != "true"):
option=input("What number would you like to add to list one?")
if(option=="1"):
listOne.append(1)
elif(option=="2"):
listOne.append(2)
if(listOne==listRight):
right="true"
Thanks for the help.
Note: There won't be any duplicates in my lists. One will be a list of 3 numbers i.e. [1,4,7] the other list will be anywhere from zero to nine numbers only used the numbers 1-9. I want to be able to check if all 3 of the the numbers are anywhere in the second list regardless if there's extra numbers. Like if [1,5,9] was the first list and [7,1,3,6,9,5] was the second list it would come back true that they equal each other.