我收到以下转换错误,不确定实际问题在哪里。
练习: 编写一个接受两个正整数的函数,它是矩形的高度和宽度,并返回一个包含该矩形的面积和周长的列表。
def Area_of_a_Rectangle(width, height):
'''Calculate the area'''
Area = width * height
# calculate the Perimeter'''
Perimeter = 2 * (width + height)
print("\n Area of a Rectangle is: ",Area)
print(" Perimeter of Rectangle is: ",Perimeter)
width = float(input("Please Enter the Width of a Rectangle: ")) # This line errs out.
height = float(input("Please Enter the Height of a Rectangle: "))
Area_of_a_Rectangle(width, height)
**Error:**
Error in executing student function:
ValueError at line 11
could not convert string to float:
答案 0 :(得分:0)
问题在于输入的值。如果输入数值,第11行不应该给出该错误。