MATATA EMMANUEL wrote: > Hi there, > > Can anyone tell me how I'm having trouble executing this piece of code: > > mpg = raw_input (" Enter your mileage:") > distance = raw_input ("Enter your distance:") > galon_price = raw_input ("Enter you cost per gallon:") > make = "Honda" > model = "Accord" > ## > print make, model, "mileage is", mpg, "miles per gallon" > print "Total trip cost is US$", distance / (mpg * gallon_price) > > I get this error when I run it: > > print "Total trip cost is US$", distance / (mpg * gallon_price) > TypeError: unsupported operand type(s) for * > The type which raw_input() returns is a string, so '120'*'5' multiplies two strings. Perhaps you can convert your input to a type you need. ( e.g. float ), but you have to check for a ValueError-Exception if the conversion fails.
HTH Ewald _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor