Error string to float
<p>This is my code. I am doing a beginer execise. When I run the program </p>

<p>I can put the values, but when I go out of the loop the following error message appears:</p>

<pre><code> a + = float (input ("Enter the product cost"))
</code></pre>

<p>ValueError: could not convert string to float:</p>

<p>Can someone help me?</p>

<p>Here it goes:</p>

<pre><code>e = 0.25
f = 0.18
a = 0.0

while True:
    a += float(input("Enter the product cost:  "))
    if a == "":        
        break

b = a*e
c = a*f
d = a+b+c

print ("tax: " + b)
print ("tips: " + c)
print ( "Total: " + d)
</code></pre>

<p>You are combining two operations on the same line: the input of a string, and the conversion of the string to a <code>float</code>. If you enter the empty string to end the program, the conversion to <code>float</code> fails with the error message you see; the error contains the string it tried to convert, and it is empty.</p>

<p>Split it into multiple lines:</p>

<pre><code>while True:
    inp = input("Enter the product cost:  ")
    if inp == "":        
        break
    a += float(inp)
</code></pre>

python python-3.x