CS50P问题集5 test_bank问题:check50提示未以代码0退出
CS50P 问题集5代码检测异常求助
我正在学习CS50P课程,目前推进到问题集5的第二题。本地运行代码时程序能正常以退出码0结束,但用check50检测时,却提示代码未以退出码0退出。
我的功能代码(bank.py)如下:
def main(): x = input("Greeting: ") print(value(x)) def value(greeting): greeting = greeting.lower().strip() if greeting.startswith("hello"): return "$0" elif greeting.startswith("h"): return "$20" else: return "$100" if __name__ == "__main__": main()
测试该value函数的代码如下:
from bank import value def test_hello(): assert value("hello") == "$0" assert value("HELLO, mark") == "$0" def test_h_words(): assert value("hi") == "$20" assert value("howdy") == "$20" def test_other_words(): assert value("money") == "$100" assert value("food") == "$100" def test_h_in_middle(): assert value("she") == "$100" def test_numbers(): assert value("123") == "$100" def test_symbols(): assert value("!@#$%^&*") == "$100"
check50报错截图:
内容的提问来源于stack exchange,提问作者jfgjhfgj
相关产品推荐
相关产品推荐

