"TypeError: can only concatenate tuple (not "float") to tuple"
<p>I am writing a program to open and read a txt file and go through loops each line. multiply values in 2nd column and 4th column and assign it to 5th column.</p>

<pre><code>A 500.00 A 84.15  ?

B 648.80 B 77.61  ?

C 342.23 B 39.00  ?
</code></pre>

<p>this is part of codes I wrote, </p>

<pre><code>for line in infile:
    a,b,c,d = line.split()
    e = eval(b) + eval(d)

    print("{0:20}${1:20}{2:20}${3:20}{4:20}".format(a,b,c,d,e),file=outfile)
</code></pre>

<p>I kept getting an error saying,</p>

<blockquote>
  <p>File "C:/Users/hee lim/Desktop/readfile2.py", line 19, in main
      e = eval(b) + eval(d)
  TypeError: can only concatenate tuple (not "float") to tuple</p>
</blockquote>

<p>I covert strings into numbers using "eval" to multiply those numbers. 
I don't understand why it flags an error.</p>

<p>thank you for your help. </p>

<p>Looking at this information, I could only tell that the value returned by <code>eval</code> of <code>b</code> and <code>d</code> are of <code>float</code> and <code>tuple</code> type. And you can not do <code>+</code> on <code>float</code> and <code>tuple</code>. For example:</p>

<pre><code>&gt;&gt;&gt; 5.0 + (2 ,3)
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
TypeError: unsupported operand type(s) for +: 'float' and 'tuple'
</code></pre>

<p>For debugging, add <code>print line</code> at the start of <code>for</code> loop to see at what value it is raising error.</p>

python