11

I want to check if the From header contains the email address [email protected]:

if msg['From'] =='[email protected]':
  count+=1

This does not add one to the count because the header actually contains 'YouTube [email protected]'.

How can I adapt my code so it adds one to the counter, checking that it contains '[email protected]' anywhere in the header?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199

1 Answers1

7

Try using in.

>>> "[email protected]" in '[email protected]'
True
Kevin
  • 74,910
  • 12
  • 133
  • 166