[Tutor] Bad Operand Type

Daniel D. Laskey dlaskey@laskeycpa.com
Sun, 24 Sep 2000 23:49:01 -0400


When I type this program in the python command prompt everthing works =
well.  When I put it inside the file and try to run it I get the =
following error message.

milesTraveled =3D raw_input("How many miles did you travel? ")
gallonsUsed =3D raw_input("How many gallons of gas did you use? ")
pricePerGallon =3D raw_input("How much did one gallon of gas cost? ")

print milesTraveled
print gallonsUsed
print pricePerGallon

# Divide the number of miles by the number of gallons
# used to get MPG.
milesPerGallon =3D milesTraveled / gallonsUsed
print milesPerGallon

Traceback (innermost last):
  File "travel.py", line 24, in ?
    milesPerGallon =3D milesTraveled / gallonsUsed
TypeError: bad operand type(s) for /

Thanks,
Dan