首页 > 解决方案 > builtin_function_or_method 不支持的操作数类型

问题描述

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

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

解决方案


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


推荐阅读