Preparing git repo for final project
This commit is contained in:
33
problems/pset5/test_twttr/test_twttr.py
Normal file
33
problems/pset5/test_twttr/test_twttr.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from twttr import shorten
|
||||
|
||||
|
||||
def main():
|
||||
test_uppercase()
|
||||
test_lowercase()
|
||||
test_null()
|
||||
test_digits()
|
||||
test_punctuation()
|
||||
|
||||
|
||||
def test_uppercase():
|
||||
assert shorten('TWITTER') == 'TWTTR'
|
||||
|
||||
|
||||
def test_lowercase():
|
||||
assert shorten('twitter') == 'twttr'
|
||||
|
||||
|
||||
def test_null():
|
||||
assert shorten('') == ''
|
||||
|
||||
|
||||
def test_digits():
|
||||
assert shorten('abc123') == 'bc123'
|
||||
|
||||
|
||||
def test_punctuation():
|
||||
assert shorten('abc,') == 'bc,'
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
16
problems/pset5/test_twttr/twttr.py
Normal file
16
problems/pset5/test_twttr/twttr.py
Normal file
@@ -0,0 +1,16 @@
|
||||
def main():
|
||||
tweet = input("Input: \t\t")
|
||||
result = shorten(tweet)
|
||||
print(f"Output: {result}")
|
||||
|
||||
|
||||
def shorten(word: str) -> str:
|
||||
result = ''
|
||||
for c in word:
|
||||
if c.lower() not in ('a', 'e', 'i', 'o', 'u'):
|
||||
result += c
|
||||
return result
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user