Python exercises — intermediate

    Exercise: Compare text files with lists of names

Using a text editor, create two text files with names and surnames, one person in each line, with no spaces at the end and a space in the middle.
— Case 1 — there is a longer file, with around 15/20 people, and a shorter file with around 10 people, chosen out of the list in the first file. The task is to find the missing people in the second file. Create a third file, called «missing people» and write the missing names and surnames in it.
— Case 2 — the two files have lists of similar length, only few people are present in both files. The task is to find the people present in both files, and write them in a third file.
— Case 3 — in comparing the people, consider the possibility that the same person is written with «name surname» order in one file, and «surname name» in another file.

Hints:
It is useful to use the commands string.split() and string.strip() (if you don’t remember the use of those commands, search on the book (Lutz) or on the internet).
One possible method is to use two nested «for loops», one inside the other, the first going through the first list, the second going through the second list.

An alternative to the use of two loops is this: use only one loop, on the «longer list», and use the structure «if element not in short_list:»