11

I want to check if the From header contains the email address noreply@youtube.com:

if msg['From'] =='noreply@youtube.com':
  count+=1

This does not add one to the count because the header actually contains 'YouTube noreply@youtube.com'.

How can I adapt my code so it adds one to the counter, checking that it contains 'noreply@youtube.com' anywhere in the header?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199

1 Answers1

7

Try using in.

>>> "noreply@youtube.com" in 'YouTube_noreply@youtube.com'
True
Kevin
  • 74,910
  • 12
  • 133
  • 166