I need to run this program:
Rewrite your payment program using try and except for the program to handle non-numeric inputs amicably by printing a message and exiting the program. The following shows two program implementations:
Digite as Horas: 20
Digite a Taxa: nove
Erro, por favor, informe entrada numérica
Digite as Horas: quarenta
Erro, por favor, informe entrada numérica
O my code is as follows:
numero_horas=input("Digite o numero de horas:")
valor_hora=input("Digite o valor hora:")
print("Erro, digite numeros")
valor_total=int(numero_horas*valor_hora)
print("Valor total", valor_total)
try:
valor=int(valor_total)
print("Valor de Pagamento é:", valor)
except:
print("Inicie programa novamente")
It only gives this error:
valor_total=int(numero_horas*valor_hora)
TypeError: can't multiply sequence by non-int of type 'str'
How can I solve this problem?