Skip to content

Commit 8a18e28

Browse files
committed
Finished working on the acronym challenge, tried optimizing code for word_count
1 parent c2a58aa commit 8a18e28

File tree

5 files changed

+8
-1
lines changed

5 files changed

+8
-1
lines changed
552 Bytes
Binary file not shown.
2.35 KB
Binary file not shown.

acronym/acronym.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
1+
import re
12
def abbreviate(words):
2-
pass
3+
4+
words = re.sub("_|-", " ", words)
5+
inspected = re.findall(r"([\w]+[']?[\w]+|\d|[a-zA-Z])", words)
6+
7+
acronym = ''.join(word[0] for word in inspected)
8+
9+
return acronym.upper()
3 Bytes
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)