Python - Compare Lists, using conditions to determine Start and End of Search

0

Introduction : Program has 1 Lists and 1 Set : List = Data Entry ; Set: Comparison Data

lista_entrada = ['BBB','AAA','CCC','DDD','EEE']
    print()
    for item in lista_entrada:
        print("item")

lista_bd = {'AAA','BBB','CCC','DDD','EEE','FFF','GGG','EEE'}

Problem:

How to compare the List with the Set;

Print the same values from the item: "AAA" , do not print values older than the "AAA" item in the list. Print to "EEE"

I've tried a few things, but I do not know very well how to handle repetition loops and search functions in lists or sets: / Then I always end up falling into this problem

    
asked by anonymous 12.11.2018 / 02:09

1 answer

1
lista = ['BBB','AAA','CCC','DDD','EEE']
conjunto = {'AAA','BBB','CCC','DDD','EEE','FFF','GGG','EEE'}

aaa_encontrado = False
for item in lista:
    if item == "AAA":
        aaa_encontrado = True
    if aaa_encontrado and item in conjunto: #Imprimir os valores iguais,
        print(item)                         # a partir do item: "AAA"
    if item == "EEE":   # Imprima até o item "EEE"
        break # sai do for
    
12.11.2018 / 15:12