[Tutor] counting number of loops

Rafael Knuth rafael.knuth at gmail.com
Sat Feb 25 12:12:02 EST 2017


I want to compare two strings and count the number of identical letters:

stringB = "ABCD"
stringA = "AABBCCDDEE"
for b in stringB:
    if b in stringA:
        r = 0
        r += 1
        print (r)

How do I count the output (r) instead of printing it out?
(result should be 4). Thanks!


More information about the Tutor mailing list