Advertisement
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(
- (i['subject']).lower())
- ## check if variable is equal to urgent
- if variable.group()=='urgent':
- list.append(i['author'])
- return list
- emails1 = [
- {
- 'author': 'emil@booking.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': 'kerem@booking.com',
- 'subject': 'News',
- 'content': 'I am going to take over Emil\'s class next week. Be sure to be there!'
- },
- {
- 'author': 'staff@booking.com',
- 'subject': 'URGENT - change your password now!',
- 'content': 'Your password has expired, change your password now!!!'
- },
- {
- 'author': 'workbook@booking.com',
- 'subject': '[EXTERNAL]Whatever news have been posted...',
- 'content': 'X has done Y Urgent thing on platform Z, hooray!'
- }
- ]
- urgent_emails(emails1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement