please help me subtract the existing string from the list VideoList so we have a difference and should be formatted into a new list
JavaScript
x
9
1
Database = ["vill du ha","garry", "yao"] #this is the list of the local data we have
2
VideoList = ["garry", "vill du ha", "yao", "potato"] #this list has the same data as Database or more
3
4
#My code:
5
if len(VideoList) == len(Database):
6
print("No new videos")
7
else:
8
new_List = #i don't know what to do here but i want the list VideoLise to subtract the existing string in Data base and return what's left from VideoList as a List so the output should be NewList = ["potato"]
9
Advertisement
Answer
You can check whether the element of VideoList is present in Database or not like
JavaScript
1
11
11
1
Database = ["vill du ha","garry", "yao"]
2
VideoList = ["garry", "vill du ha", "yao", "potato"]
3
4
if len(VideoList) == len(Database):
5
print("No new videos")
6
else:
7
new_list=[]
8
for element in VideoList:
9
if not element in Database:
10
new_list.append(element)
11