a guest Mar 22nd, 2019 117 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- # -*- coding: utf-8 -*-
- Created on Fri Mar 22 20:00:53 2019
- @author: Matth
- import re
- def urgent_emails(emails):
- urgentRegex = re.compile('urgent')
- list = 
- ## loop through every email in email list
- for i in emails:
- ## construct variable that has string "urgent" if value belonging to key 'subject' contains UrGent
- variable = urgentRegex.search(
- ## check if variable is equal to urgent
- if variable.group()=='urgent':
- return list
- emails1 = [
- 'author': 'email@example.com',
- 'subject': 'Urgent: you better do your homework!',
- 'content': 'New session is coming, please get the homework ready so we can do amazing stuff!'
- 'author': 'firstname.lastname@example.org',
- 'subject': 'News',
- 'content': 'I am going to take over Emil\'s class next week. Be sure to be there!'
- 'author': 'email@example.com',
- 'subject': 'URGENT - change your password now!',
- 'content': 'Your password has expired, change your password now!!!'
- 'author': 'firstname.lastname@example.org',
- 'subject': '[EXTERNAL]Whatever news have been posted...',
- 'content': 'X has done Y Urgent thing on platform Z, hooray!'
RAW Paste Data