плохо знакомы с Python.
Я пытаюсь найти способ узнать, является ли список со связанными строками и переменными подмножеством другого списка.См. Код и результаты ниже:
y = ['test_sam_20190624.csv', 'test_phil_20190624.csv', 'test_bill_20190624.csv', 'test_jess_20190624.csv', 'test_issy_20190624.csv', 'test_clinton_20190624.csv']
x = ['sam', 'jack', 'bill', 'rodry', 'clinton']
print('\nFile list is ')
print(*y, sep="\n")
print('\nNeeded names are ')
print(*x, sep="\n")
datetoday = '20190624'
incl = [p for p in x if 'test'+p+datetoday+'.csv' in y]
not_incl = [p for p in x if 'test'+p+datetoday+'.csv' not in y]
print("\n Included")
print(*incl, sep="\m")
print("\n Not included")
print(*not_incl, sep="\n")
И вывод, приведенный ниже:
File list is
test_sam_20190624.csv
test_phil_20190624.csv
test_bill_20190624.csv
test_jess_20190624.csv
test_issy_20190624.csv
test_clinton__20190624.csv
Needed names are
sam
jack
bill
rodry
clinton
Included
Not included
sam
jack
bill
rodry
clinton
Process finished with exit code 0
Но я бы ожидал, что incl = ['sam' 'bill 'clinton']
как вывод наверняка?И выходы будут:
Included
sam
bill
clinton
Not included
jack
rodry
Куда я иду не так?Может быть, в конкатенации строк?