当我运行此代码时,我收到此错误ValueError:int()的基数为10的无效文字:'kitchen'
我是Python的新手,所以任何帮助都会非常感激。 提前谢谢。
st1 = []
number = 0
room_type =0
walls=0
print ("welcome to our painting cost estimate calculator")
print ("please enter the following information")
customer_number = input("please enter your telefone number")
date = input("please enter the date of the estimate \n(in short form)")
num_rooms = input("please enter the number of rooms that you wish to be painted")
int(num_rooms)
while int(room_type) < int(num_rooms):
room_type = input("please enter the room name")
list1.append(room_type))
while int(walls)< int(room_type):
wall = input ("enter the nmber of walls in",room_type,)
list1.append (float(2,wall))
wallpaper = input("does wallpaper need to be removed (y/n)\nthis costs £70")
if wallpaper == ("y"):
Total_price + 70*(num_rooms)
if wallpaper == ("n"):
measurements()
def measurements():
measure = input("please enter the dementions for",room_type,"as follows Height/width")
list1.insert(2,measure)
答案 0 :(得分:0)
您无法在字符串上调用int()
。这发生在
while int(walls)< int(room_type):
答案 1 :(得分:0)
因为我失去了一个时刻:
def getrooms(wall_paper_removal_cost, cost_per_square_meter_paint):
num_rooms = input('please input the number of rooms you like to paint:')
rooms = []
for i in range(1, int(num_rooms) + 1):
print ()
print ('for room number ' + str(i) + ':')
room_name = input('what is the name of the room:')
walls = int(input('how many walls need to be painted:'))
paper = int(input('how many walls need wall paper removed:'))
paper_cost = paper * wall_paper_removal_cost
paint_cost = 0
for t in range(1, walls + 1):
print ('for room ' + room_name + ' wall ' + str(t) + ':')
height = int(input('what is the height in meters:'))
width = int (input('what is the width in meters:'))
paint_cost += height * width * cost_per_square_meter_paint
rooms.append([room_name, walls, paper, paper_cost, paint_cost])
return rooms
def printcost(rooms):
# alignment of printing need to be done properly
# probably using ''.ljust() and ''.rjust() to make it look good
total = 0
for i in range(0, len(rooms)):
print()
print ('Room:' + rooms[i][0])
print (' Number of walls to be painted: ' + str(rooms[i][1]))
print (' cost: ' + str(rooms[i][4]))
print (' Number of wallpaper removal : ' + str(rooms[i][2]))
print (' cost: ' + str(rooms[i][3]))
total += rooms[i][3] + rooms[i][4]
print ('===================================================================')
print (' total: ' + str(total))
def main():
# set your costs for calculation
cost_per_square_meter_paint = 12
wall_paper_removal_cost = 70
# get the details of each room
rooms = getrooms(wall_paper_removal_cost, cost_per_square_meter_paint)
#print out the estimate
printcost(rooms)
return
if __name__ == '__main__':
main ()