2016-06-21 13 views
-1

, wenn ich diesen Code ausführen ich diesen Fehler Valueerror: invalid wörtlichen für int() mit Basis 10: ‚Küche‘ungültig wörtliche für int() mit Basis 10: ‚Küche‘

ich bin sehr neu in Python So würde jede Hilfe sehr geschätzt werden. Vielen Dank im Voraus.

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

Nun, was genau erwarten Sie, es zu tun, wenn Sie versuchen, zu konvertieren ' 'kitchen'' auf eine ganze Zahl ?! – jonrsharpe

Antwort

0

Sie können int() nicht auf einer Zeichenfolge aufrufen. Dies geschieht in der Linie

while int(walls)< int(room_type): 
+0

Nun können Sie * int mit einer Zeichenkette aufrufen, aber wenn es sich nicht um eine Ganzzahl ("123", "10101" usw.) handelt, sollten Sie nicht erwarten, dass es sehr glücklich ist. – jonrsharpe

0

Als ich einen verlorenen Moment hatte:

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()