1. When I do the addition (For example, if I choose 5 cheese and 5 crackers) it comes out as 55 instead of 10.
2. When I do the multiplication (Same example as above for values)I get an error which says its on line 11. This is the message I receive:
#line 11, in cheese_and_crackers
print cheese * crackers
type error: can't multiply sequence by non-int of type 'str'
3. When I remove the multiplication part of my program and try making the values placed by the user (cheese+100 and crackers +1000) I get this error message.
#print (cheese + 100, crackers + 1000)
TypeError: cannot concatenate 'str' and 'int' objects.
I've been racking my brains on this program for three days and I think I'd have better luck hitting my head with a hammer. Any and all advice would be greatly appreciated.
This is the program below:
def cheese_and_crackers(): print "How many cheeses do you have? " cheese=raw_input() print "How many boxes of crackers do you have? " crackers=raw_input() print "Man, that's enough for a party!" print "Get a blanket.\n" print "We can also add the amount %s cheese and %s crackers: "% (cheese, crackers) print (cheese + crackers) print "We can also multiply the amount %s and %s crackers:" % (cheese, crackers) print (cheese * crackers) print "We can combine two variables and math:" print (cheese + 100, crackers + 1000) cheese_and_crackers()

New Topic/Question
Reply


MultiQuote





|