0

Write a program to prompt the user for hours and rate per hour to compute gross pay:

hours = input('Enter the hours you worked = ')
rate = input('Enter the rate = ')
pay = hours*rate
print(pay)

I am getting an error:

File "Hello", line 3, in pay = hours*rate TypeError: can't multiply sequence by non-int of type 'str'

khelwood
  • 55,782
  • 14
  • 81
  • 108

2 Answers2

0
hours = input('Enter the hours you worked = ')
rate = input('Enter the rate = ')
pay = int(hours)* int(rate)
print(pay)

Try this.

Ishan Arora
  • 124
  • 1
  • 6
0

You could try something like

hours = int(input('Enter the hours you worked = '))
rate = int(input('Enter the rate = '))
pay = hours*rate
print(pay)

see How can I read inputs as numbers?

Nikos Bosse
  • 144
  • 11