How to compare individual characters in two strings in Python 3

Use zip:

def compare(a, b):
    for x, y in zip(a, b):
        if x == y:
            ...

Leave a Comment