This is quite an interesting task, actually. I'm supposed to create a list that merges lines from two files: the original one and its updated version. The lines should be preceded by suitable labels: SAME, REMOVED OR ADDED. The tricky requirement is that the ADDED and REMOVED labels should not be used consecutively: there always has to be a line with the SAME label between them. I can't imagine how it is possible to fully satisfy this condition, taking into consideration that the number of SAME lines might be just insufficient to ensure the alteration. I tried checking for the previous label used before adding every new line, but that strategy didn't get me anywhere (just the code became cumbersome). For instance, if the previous label is ADDED or REMOVED, and the next label is also ADDED or REMOVED, what should I do with it? Should I postpone adding the next lines to the list before a line with the SAME label is found? But what if there are too many postponed lines? So, here is my code attached. I tried it with with some files of my own, here is the input and output I got. File1 ("original"): I love the sunset. It's a beautiful time. The day is all ahead. The buses are not making any noise. The birds are singing. It's neither hot, nor cold. Cool! File2 ("updated"): I love the sunset. It's a romantic time. Could one imagine a better one? The day is all ahead. The buses start going around the city. The birds are singing. It's neither hot, nor cold. Cool! Precious! Output (the contents of the "lines" list): SAME : I love the sunset. ADDED : It's a romantic time. REMOVED : It's a beautiful time. ADDED : Could one imagine a better one? SAME : The day is all ahead. ADDED : The buses start going around the city. REMOVED : The buses are not making any noise. SAME : The birds are singing. It's neither hot, nor cold. SAME : Cool! ADDED : Precious! What can I do about the sequence of labels?