How to compare 2 text and replace the differences with python?

Question:

So I want to compare 2 hex lines and find the differences.
But I want it not only to show the differences, but its just replace all the differences.

I wanna to turn this :

E2 34 3D A6 00 C2 00 95
79 34 C0 AB 00 C2 00 95

Into this :
?? 34 ?? ?? 00 C2 00 95
Asked By: nemesisid

||

Answers:

You can something like this,

l1 = "E2 34 3D A6 00 C2 00 95" 
l2 = "79 34 C0 AB 00 C2 00 95"
    
" ".join(i if i==j else '??' for i,j in zip(l1.split(), l2.split()))
# '?? 34 ?? ?? 00 C2 00 95'
Answered By: Rahul K P
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.