-1
I’m starting in Python and I’m doing some exercises, I did this spent fuel, but it does not show me the end of the program, ie the result, what is the error?
nome = input("Qual é o seu nome?")
gasto = input("{}, digite o tempo gasto na viagem (em horas): ".format(nome))
velocidade = input('{}, digite agora a velocidade média praticado na viagem: '.format(nome))
consumo = float(velocidade/12)
print("Foram gastos ", consumo, " litros de combustível.")
The error generated is:
Traceback (Most recent call last): File "/home/Ralf/Pycharmprojects/Projetopython/Gasto_combustivel.py", line 4, in consumption = float (speed / 12) Typeerror: Unsupported operand type(s) for /: str and 'int'
Welcome Ralf, the Fchagas answer is correct. However, I advise you to read this question: How to convert a string variable to int? It will help you better understand conversion and possible treatments with exceptions.
– Luiz Augusto