builtin_function_or_method的不支持的操作数类型

问题描述 投票:-3回答:1

我的代码有问题。我需要创建一个代码,说明输入的数字是偶数还是奇数。代码是

print ("enter a number")
a = input
if a% 2 == 0:
    print ("even")
else:
    print ("odd")

错误是:

TypeError: unsupported operand type (s) for%: 'builtin_function_or_method' and 'int'

我应该改变什么?

谢谢。

python
1个回答
0
投票

您需要先将输入转换为整数。

© www.soinside.com 2019 - 2024. All rights reserved.