Skip to content

Commit 2612eff

Browse files
committed
pset7 q4,5 code
1 parent f9be4df commit 2612eff

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

week7/response/response.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from validator_collection import checkers
2+
3+
email = input("What's your email address? ")
4+
5+
if checkers.is_email(email):
6+
print("Valid")
7+
else:
8+
print("Invalid")

week7/um/test_um.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import pytest
2+
from um import count
3+
4+
def test_all_cases_count():
5+
assert count("um, yeah you got that yummy yummy, yummy yummy, yuuummmmmmy yuummmy, UM lol") == 2

week7/um/um.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import re
2+
import sys
3+
4+
5+
def main():
6+
print(count(input("Text: ")))
7+
8+
9+
def count(s):
10+
return len(re.findall(r"\bum\b", s, re.IGNORECASE)) # \b can be learnt at "https://docs.python.org/3/library/re.html#regular-expression-syntax:~:text=of%20the%20string.-,%5Cb,-Matches%20the%20empty"
11+
12+
13+
if __name__ == "__main__":
14+
main()

0 commit comments

Comments
 (0)