s = 'coffee coke tea lemonade milk sprite'
{ c:s.count(c) for c in ''.join([ w[1:] for w in s.split()
if 'e' not in w[-3:-1] and 'o' in w[:4] ]) }
# (’’.join([ w[1:] for w in s.split())
how does the w
work is it run through the s.split() that has a total of 6 elements? or through each letter in the separated strings(e.g. 'coffee' etc. )? Why is the answer for this comprehension {'o': 3, 'k': 2, 'e': 7, 'm': 2, 'n': 1, 'a': 2, 'd': 1}
.
I understand why it is a dictionary but the variable c
and w
are confusing to me, currently I think that the value for those variable are changing as the loop goes but I don't understand how the other code effects how they change.