B
B
Bomber992021-06-30 12:27:49
Python
Bomber99, 2021-06-30 12:27:49

How to select strings contained in another library from a library?

There are two libraries stroka contains links, the second library gorod contains the city. the task is to select lines that do not contain a city.

wrote this code:

for line_stroka in stroka:
    if gorod1 in line_stroka:
        continue
    elif gorod2 in line_stroka:
        continue
    elif gorod3 in line_stroka:
        continue
    elif gorod4 in line_stroka:
        continue
    elif gorod5 in line_stroka:
        continue
    elif gorod6 in line_stroka:
        continue
    elif gorod7 in line_stroka:
        continue
    elif gorod8 in line_stroka:
        continue
    elif gorod9 in line_stroka:
        continue
    elif gorod10 in line_stroka:
        continue
    elif gorod11 in line_stroka:
        continue
    elif gorod12 in line_stroka:
        continue
    elif gorod13 in line_stroka:
        continue
    elif gorod14 in line_stroka:
        continue
    elif gorod15 in line_stroka:
        continue
    elif gorod16 in line_stroka:
        continue
    elif gorod17 in line_stroka:
        continue
    elif gorod18 in line_stroka:
        continue
    elif gorod19 in line_stroka:
        continue
    elif gorod20 in line_stroka:
        continue
    elif gorod21 in line_stroka:
        continue
    elif gorod22 in line_stroka:
        continue
    elif gorod23 in line_stroka:
        continue
    else:
        stroka_beth_gorod.append(line_stroka)

how can it be reduced to two cycles?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question