[Python] Counting differences between two strings

Discussão em 'Python' iniciado por Stack, Fevereiro 18, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to count the number of differences between two imported strings (seq1 and seq2, import code not listed), but am getting no result when running the program. I want the output to read something like "2 differences." Not sure where I'm going wrong...

    def difference (seq1, seq2):
    count = 0
    for i in seq1:
    if seq1 != seq2:
    count += 1
    return (count)
    print (count, "differences")

    Continue reading...

Compartilhe esta Página