[Tutor] reading strings and calculating totals
Richard Dillon
dillonrw at comcast.net
Sat Aug 30 22:26:57 CEST 2014
When I tried
total = 0
with open('/Users/richarddillon/Desktop/numbers.txt', 'r') as infile:
for line in infile:
total += float(line)
print(total)
Python returned "ValueError: could not convert string to float: "
Richard
On Aug 30, 2014, at 1:13 PM, Alan Gauld <alan.gauld at btinternet.com> wrote:
> total = 0
> with open('/Users/richarddillon/Desktop/numbers.txt', 'r') as infile:
> for line in infile:
> total += float(line)
> print(total)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140830/d18c38be/attachment-0001.html>
More information about the Tutor
mailing list