Y
Y
Yaroslav2020-06-13 12:49:54
Python
Yaroslav, 2020-06-13 12:49:54

How to compare 2 txt files for a partial match in a line?

There are 2 files all.txt (lines with random information about people like "annmatilda smith [email protected] etc") and female_name.txt (a list of female names).
How to compare all lines in the file all.txt and female_name.txt and display the result in the third file result.txt so that it contains lines without female names? Those. this is a search for a partial match in a string in essence.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
artshelom, 2020-06-13
@Yaxoo

You read the file line by line, take the first line from the first one and compare it using .contains(), with another line. And so line by line

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question