Builtin_function_or_method的不受支持的操作数类型

时间:2018-10-14 09:33:45

标签: python

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

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'

我应该改变什么?

谢谢。

1 个答案:

答案 0 :(得分:0)

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

相关问题