let - 9 months ago 55

Python Question

im submitting this code..

`a = float(input())`

b = float(input())

c = float(input())

if abs(b - c) < a < (b + c) and abs(a - c) < b < (a + c) and abs(a - b) < c < (a + b):

print("Perimetro = " + str(a + b + c))

else:

print("Area = " + str(((a + b) * c) / 2))

and for me it was correct, but, as a response, i get:

`Traceback (most recent call last):`

File "Main.py", line 1, in <module>

a = float(input())

ValueError: could not convert string to float: '6.0 4.0 2.0'

Command exited with non-zero status (1)

which i dont get it cause i converted the strings in the begginning.

what am i doing wrong here?

thanks x

Answer Source

The issue is that you are entering all the three values at once. Add one value and then press enter. For example:

```
>>> a = float(input())
6.0
>>> b = float(input())
4.0
>>> c = float(input())
2.0
>>> a, b, c
(6.0, 4.0, 2.0)
```

OR, get the single string and `split`

the string to assign the value to `a`

, `b`

and `c`

. For example:

```
>>> a, b, c = [float(item) for item in input().split()]
6.0 4.0 2.0
>>> a, b, c
(6.0, 4.0, 2.0)
```