首页 > 解决方案 > 当我完成此代码时,我收到“TypeError:'>' 在 'float' 和 'str' 的实例之间不支持”。我究竟做错了什么?

问题描述

这是代码

wagesAmount = float(input("Enter Wages Amount: "))

numberOfHours = float(input("Enter Number Of Hours Worked: "))

totalWagesAmount = (wagesAmount) * (numberOfHours)

if totalWagesAmount > "0":

   printtotalWagesAmount

我还需要添加一个 else 语句,但我只是想先解决这个问题

标签: pythonerror-handlingcompiler-errorstypeerror

解决方案


你必须删除""on0因为"0" != 0

if totalWagesAmount > 0:

推荐阅读