Re: read in a list in a file to list

2017-04-11 Thread Rick Johnson
On Sunday, April 9, 2017 at 4:22:59 PM UTC-5, john polo wrote: > On 4/8/2017 3:21 PM, breamore...@gmail.com wrote: > > On Saturday, April 8, 2017 at 7:32:52 PM UTC+1, john polo wrote: > > I'll start you off. > > > > with open("apefile.txt") as apefile: > > for line in apefile: > > do

Re: read in a list in a file to list

2017-04-10 Thread Erik
On 09/04/17 22:22, john polo wrote: The new attempt gives me a list, now I have to figure out how to deal with unwanted quotation marks and spaces. datFil = open("apelist.txt") datObj = datFil.read() datObj2 = datObj.replace('" ','') #added this comment while writing this email: I guess I c

Re: read in a list in a file to list

2017-04-09 Thread Chris Angelico
On Mon, Apr 10, 2017 at 7:22 AM, john polo wrote: > Thanks for the reply. I looked back through the methods for strings. I also > looked at the csv module, but I couldn't tell which one of those would help. > The small .txt file does have commas, but with the weird form of listname = > [1] , [2],

Re: read in a list in a file to list

2017-04-09 Thread john polo
On 4/8/2017 3:21 PM, breamore...@gmail.com wrote: On Saturday, April 8, 2017 at 7:32:52 PM UTC+1, john polo wrote: Hi, I am using Python 3.6 on Windows 7. I have a file called apefile.txt. apefile.txt's contents are: apes = "Home sapiens", "Pan troglodytes", "Gorilla gorilla" I have a scrip

Re: read in a list in a file to list

2017-04-08 Thread Rick Johnson
@John General debugging methodology dictates that when your output does not match your expectation, you must never assume anything. Here you made the fatal mistake of assuming that: (1) files are stored as list objects, or (2) Python automatically converts file data to list objects, or (3) that py

Re: read in a list in a file to list

2017-04-08 Thread boB Stepp
On Sat, Apr 8, 2017 at 3:21 PM, wrote: > On Saturday, April 8, 2017 at 7:32:52 PM UTC+1, john polo wrote: >> Hi, >> >> I am using Python 3.6 on Windows 7. >> >> I have a file called apefile.txt. apefile.txt's contents are: >> >> apes = "Home sapiens", "Pan troglodytes", "Gorilla gorilla" >> >> I

Re: read in a list in a file to list

2017-04-08 Thread breamoreboy
On Saturday, April 8, 2017 at 7:32:52 PM UTC+1, john polo wrote: > Hi, > > I am using Python 3.6 on Windows 7. > > I have a file called apefile.txt. apefile.txt's contents are: > > apes = "Home sapiens", "Pan troglodytes", "Gorilla gorilla" > > I have a script: > > apefile = open("apefile.tx

read in a list in a file to list

2017-04-08 Thread john polo
Hi, I am using Python 3.6 on Windows 7. I have a file called apefile.txt. apefile.txt's contents are: apes = "Home sapiens", "Pan troglodytes", "Gorilla gorilla" I have a script: apefile = open("apefile.txt") apelist = apefile.read() for ape in apelist: print("one of the apes is " + ape