[Tutor] counting number of loops

2017-02-25 Thread Rafael Knuth
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! __

Re: [Tutor] counting number of loops

2017-02-25 Thread Alan Gauld via Tutor
On 25/02/17 17:12, Rafael Knuth wrote: > 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