twttr.py:
Код: Выделить всё
def main():
user = str(input("Input: "))
print(shorten(user))
def shorten(word):
word = str(word)
result = ''
vowels = ['a', 'e', 'i', 'o', 'u']
for letter in word:
if letter.lower() not in vowels:
result += letter
return result
if __name__ == "__main__":
main()
Код: Выделить всё
from twttr import shorten
def test_default():
assert shorten("") == ""
def test_uCase():
assert shorten("twITter") == "twTtr"
def test_lCase():
assert shorten("TWitTER") == "TWtTR"
def test_int():
assert shorten(0) == "0"
assert shorten(452) == "452"
assert shorten("21") == "21"
def test_float():
assert shorten(3.14) == "3.14"
assert shorten("2.71e") == "2.71"
def test_punc():
assert shorten("..,-!?ab:i") == "..,-!?b:"
[img]https://i.sstatic.net /38iU1blD.png[/img]
Код: Выделить всё
:) test_twttr.py exist
:( correct twttr.py passes all test_twttr checks
expected exit code 0, not 1
:| test_twttr catches twttr.py without vowel replacement
can't check until a frown turns upside down
:| test_twttr catches twttr.py without capitalized vowel replacement
can't check until a frown turns upside down
:| test_twttr catches twttr.py without lowercase vowel replacement
can't check until a frown turns upside down
:| test_twttr catches twttr.py omitting numbers
can't check until a frown turns upside down
:| test_twttr catches twttr.py printing in uppercase
can't check until a frown turns upside down
:| test_twttr catches twttr.py omitting punctuation
can't check until a frown turns upside down
Подробнее здесь: https://stackoverflow.com/questions/792 ... 50p-pset-5
Мобильная версия