At the entrance we are given the following data:
4 A B : A C : A D : BC 4 AB BD CD DA The code is:
n=int(input()) d={} for i in range(n): line=input().split(':') if len(line) == 1 : d[line[0]] = [''] else: d[line[0].strip()] = line[1].split() z = int(input()) list = [] for i in range(z): request = input().split() list.append(request[0]) We will have a dictionary like:
{'C': ['A'], 'D': ['B', 'C'], 'B': ['A'], 'A': ['']} The list will be like this:
['A', 'B', 'C', 'D'] And the question itself: At the end of the code I want to write something like
for j in list: if list in d.values(): print('Yes') else: print('No') But I’ll get "No" everywhere as output. 2 objects 'A' and A will be compared, instead of A and A (without quotes). How to turn this check?
моё_сравние(['A', 'B', 'C', 'D'], ['A']) == 'Yes'orмоё_сравние(['A', 'B', 'C', 'D'], ['A']) == 'No'- what do you want to receive and why? - jfs