-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCOFFEE!
More file actions
27 lines (14 loc) · 996 Bytes
/
Copy pathCOFFEE!
File metadata and controls
27 lines (14 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
Description: John is really excited about coffee. He wrote some text messages earlier, but he's worried that they didn't convey his enthusiasm for coffee, so he's decided to resend them with coffee in all-caps:
COFFEE
Task: Write a function "coffee" that accepts a string as a parameter and returns that string with every instance of coffee in all caps.
Input: string. The word "coffee" may occur more than once. It may have some capital letters or already be in all-caps. There may be punctuation in the string too. It will not be part of another word like "Coffeeburger", which isn't a word anyway.
Output: string with all instances of coffee in all-caps:
Examples:
Input: "Did I only have two cups of coffee this morning? I need more." Output: "Did I only have two cups of COFFEE this morning? I need more."
Input: "Coffee! Buy me a COFFEE!" Output: "COFFEE! Buy me a COFFEE!"
Good luck!
*/
import re
def coffee(s):
return re.sub(r'coffee','COFFEE',s, flags=re.IGNORECASE)