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

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -