I have a problem at Vscode Terminal

Asked

Viewed 23 times

0

v = float(input('Valor: R$ '))
b = 5.33
print(f'U$ {v * b:.2f}')

When I make some input code, give an error in the terminal after some time without typing something.

Erro: invalid literal for int() with base ou could not convert string to float
  • I have an idea of what it is, but to confirm I would like you to put me an example of input for the script.

1 answer

0

You are probably typing a value with the "," (comma) as decimal separator ex: 1,23, try typing the number with decimal box separated by point "." ex: 1.23.

Another alternative is to add a treatment to the input before converting to float with the method .replace(), replacing the comma with the dot:

v = float(input('Valor: R$ ').replace(",", "."))
b = 5.33
print(f'U$ {v * b:.2f}')

Browser other questions tagged

You are not signed in. Login or sign up in order to post.