我们必须询问用户在一个月内使用了多少分钟,并将其乘以0.10,以获得他们在分钟上花费的时间。
代码:
mins = input("How many minutes have you used this month? ")
minsprice = float(mins)*0.10
print ("You have used",round(mins,2),"GBP worth of minutes this month.")
它返回以下错误:
Traceback (most recent call last):
File "C:\Users\User\Downloads\assessment.py", line 23, in
print ("You have used",float(round(mins,2)),"GBP worth of minutes this month.")
TypeError: type str doesn't define __round__ method
发布于 2021-03-01 14:42:43
我想你打错了。你写mins。它应该是minsprice最后一行。这就是错误发生的原因。试试这个
mins = input("How many minutes have you used this month? ")
minsprice = float(mins)*0.10
print ("You have used",round(minsprice,2),"GBP worth of minutes this month.")
https://stackoverflow.com/questions/37710950
复制相似问题