问题,为什么我的程序在调用checkInteger函数时不进行处理?

2024-10-02 00:43:21 发布

您现在位置:Python中文网/ 问答频道 /正文

为什么调用checkInteger函数时程序没有处理

def main():
    print("Kaylees Prime Number Checker")
    numChoice = int(input("Please type a number: "))
    checkInteger()

def checkInteger(numChoice):
    if number % 2 == 0:
        print("Your number is not prime. ")
    else:
        print("Your number is prime.")

main()

Tags: 函数程序numberyourismaindefchecker
2条回答

您必须将一个参数传递给函数checkInteger,因为它被定义为在您的定义中使用一个参数

看起来您需要checkInteger的参数,还应该命名参数编号,或者将编号更改为numChoice。无论哪种方式,都必须是相同的

相关问题 更多 >

    热门问题