python - Multiplying raw_input variables -
i'm getting stuck in multiplying variables. example...
hrs = raw_input("enter hours:") float(hrs) rateperhr = raw_input("enter rate:") float(rateperhr) grosspay = (hrs) * (rateperhr)
the error i'm getting is:
traceback (most recent call last): file "hello.py", line 5, in <module> grosspay = (hrs) * (rateperhr) typeerror: can't multiply sequence non-int of type 'str'
how solve this?
i guess forgot to:
hrs = float(hrs)
and:
rateperhr = float(rateperhr)
no need parentheses:
grosspay = hrs * rateperhr
Comments
Post a Comment