What is wrong with my code?

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
create a python program below that prompts the user for their hourly pay rate and the number of hours they worked for the week and computes their pay amount. Any hours worked over 40 are paid at time-and-a-half (1.5 times the normal hourly rate).

<In what way does your code behave incorrectly? Include ALL error messages.>

<What do you expect to happen instead?>

```python

Replace this line with your code.

hours=raw_input("Enter number of hours worked:")
payrate=raw_input("Enter the hourly wage:")
extrahours = hours - 40
overtime = payrate * 1.5 * extrahours

if hours <= 40:
    pay = payrate * hours
elif hours > 40:
    pay = 40 * payrate + overtime
else:
    print "Invalid entry, please start over."
    
print "You should get paid around % dollars." %(pay)
<do not remove the three backticks above>

raw_input stores as string, you might want to convert to integer (int()) or float (float()), string math sucks.

and one small detail for later: always validate user input

1 Like

dumb question… how do i go about converting my strings to the (int())?

int() is the function call you need for the conversion, so the argument provided will be converted to a integer:

print int("3")
1 Like

hours=raw_input(“Enter number of hours worked:”)
return int(hours)
payrate=raw_input(“Enter the hourly wage:”)
return int(payrate)

so now that I do this the error of " File “python”, line 2
SyntaxError: ‘return’ outside function"
keeps coming up…

why do you use return? raw_input() is also a function call, yet you stored the result of this in a variable, why can’t you do the same for int()?

1 Like

i got it now… thank you very very much!!