I’m teaching myself Python 3.4.1 on a Mac and the book I’m using is written for
Windows users.
I’m trying to open a file on the desktop and I created a path using the
example in the book.
Any Mac users out there with a solution? My main drive is named “OS”.
Here’s my code:
def main()
I apologize in advance - This is my third week using Python (3.4.1 on a Mac)
I need to read a text file, convert the values into numbers and calculate a
total.
The total I get doesn't match the values entered in the file.
def main():
total = 0
infile = open('/Users/richarddillon/Desktop/
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 wrote:
> total
My text file has five numbers, 1-5
I don't what the problem is.
I've written the file using Word (saved as .txt ) as well as TextEdit
Python 3.4.1 on a Mac
Here's the code:
# Richard Dillon
# This program reads data from a .txt file and calculates a total
# data in text fi
I create column headings using \t
print('base1\tbase2\theight\tarea')
and I would like the numbers to align with the headings. I think that I need to
use format instead of doing this:
print(A,' ',B,' ',C,' ',int(area1))
print(D,' ',E,' ',F,' ',int(area2))
b