cakes = int(input('How many cakes? ==> '))
donuts = int(input('How many dozens of donuts? ==> '))
cookies = int(input('How many dozen cookies? ==> '))
cake_eggs = 2
cake_butter = .5
cake_sugar = 1
cake_flour = 1.5
cookie_eggs = 2
cookie_butter = 2.5
cookie_sugar = 2
cookie_flour = 8
donuts_eggs = 3
donuts_butter = .25
donuts_sugar = .5
donuts_flour = 5
total_butter = cake_butter*cakes + cookie_butter*cookies + donuts_butter*donuts
total_eggs = cake_eggs*cakes + cookie_eggs*cookies + donuts_eggs*donuts
total_sugar = cake_sugar*cakes + cookie_sugar*cookies + donuts_sugar*donuts
total_flour = cake_flour*cakes + cookie_flour*cookies + donuts_flour*donuts
print('You need to order : \n' + 'Eggs=" + str(total_eggs)+"\n' + 'Butter=" + str(total_butter) +"\n' + 'Sugar : ' + str(total_sugar) + '\n' + 'Flour=" + str(total_flour) )
Here, to concatenate string with numbers, you have to convert number to string, using str() method.
1
solved Python coding trouble [closed]