【发布时间】:2021-09-04 14:52:04
【问题描述】:
我正在尝试使用 python 编写三角形区域,它显示不支持的操作数
height= print(float(input("Enter height ")))
base=print(float(input("Enter base ")))
area=float(height*base)/2
print('Area of triangle is: ', area)
错误信息
面积=浮动(高度*底)/2 类型错误:* 不支持的操作数类型:“NoneType”和“NoneType”
【问题讨论】:
-
你不需要打印
input语句 -
print将其参数打印到屏幕并返回None,因此您的前两个分配使None -
您将
print分配给height和base。只需使用height = float(input("Enter height "))
标签: python python-3.8