-1

Traceback (most recent call last): File "E:/Portable Python 3.2.5.1/Tasks/Wk7", line 16, in

monthlySalary = hourPay * 0.1

TypeError: can't multiply sequence by non-int of type 'float'

#Input hoursWorked
#Input hourPay
#Ask “Consultancy income? (Leave blank if none)”
#   If value:
#       Input consultFee
#       monthlySalary = ((hourPay - (hourPay * 0.1)) * hoursWorked) + (consultFee – (consultFee * 0.2))
#   Elif no value:
#       monthlySalary = hoursWorked * hourPay
#print (“The monthly wage is $”,monthlySalary)

hoursWorked = input ("Hours worked: ")
hourPay = input ("Hour pay: $")

consultFee = input ("Consultant fee? (Leave blank if none): $")
consultFee == ''
monthlySalary = hourPay * 0.1
'' == False
monthlySalary = ((hourPay - (hourPay * 0.1)) * hoursWorked) + (consultFee - (consultFee * 0.2))

print ("The monthly salary is: $",(int(monthlySalary)))

1 Answers1

0

Change

monthlySalary = hourPay * 0.1

to

monthlySalary = float(hourPay) * 0.1

The reason is that input or raw input are taking in strings that you must first convert to their proper type.

Reblochon Masque
  • 35,405
  • 10
  • 55
  • 80
  • 2
    Please do not answer obvious duplicate questions, and if you feel the need to do so, at least provide an answer that explains the issue, not just proposes a fix that leaves OP no wiser than before. – l4mpi May 08 '14 at 10:44