Skip to content

Commit c21c317

Browse files
committed
test_twttr
1 parent ec800e6 commit c21c317

File tree

3 files changed

+49
-17
lines changed

3 files changed

+49
-17
lines changed

Problem Set 2/twttr/twttr.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
1-
def main():
2-
word = input("Input: ")
3-
print("Output: ", end="")
4-
word_without_vowel = shorten(word)
5-
print(word_without_vowel)
6-
1+
inp = input("Input: ")
2+
print("Output: ", end="")
73

8-
9-
def shorten(word):
10-
word_without_vowel = ''
11-
for letter in word:
12-
if not letter.lower() in ['a', 'e', 'i', 'o', 'u']:
13-
word_without_vowel += letter
14-
return word_without_vowel
15-
16-
17-
if __name__ == "__main__":
18-
main()
4+
for letter in inp:
5+
if not letter.lower() in ['a', 'e', 'i', 'o', 'u']:
6+
print(letter, end="")
7+
print()
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from twttr import shorten
2+
3+
def main():
4+
test_upper_lower_cases()
5+
test_numbers()
6+
test_punctuation()
7+
8+
9+
# Test upper and lower cases
10+
def test_upper_lower_cases():
11+
assert shorten('twitter') == 'twttr'
12+
assert shorten('TWITTER') == 'TWTTR'
13+
assert shorten('TwiTter') == 'TwTtr'
14+
15+
# Test numbers
16+
def test_numbers():
17+
assert shorten('1234') == '1234'
18+
19+
# Test punctuation
20+
def test_punctuation():
21+
assert shorten('!?,.') == '!?,.'
22+
23+
24+
if __name__ == "__main__":
25+
main()

Problem Set 5/test_twttr/twttr.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
def main():
2+
word = input("Input: ")
3+
print("Output: ", end="")
4+
word_without_vowel = shorten(word)
5+
print(f'{word_without_vowel}')
6+
7+
8+
9+
def shorten(word):
10+
word_without_vowel = ''
11+
for letter in word:
12+
if not letter.lower() in ['a', 'e', 'i', 'o', 'u']:
13+
word_without_vowel += letter
14+
return word_without_vowel
15+
16+
17+
if __name__ == "__main__":
18+
main()

0 commit comments

Comments
 (0)