read in a list in a file to list

john polo jpolo at
Sat Apr 8 14:32:20 EDT 2017


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 =
for ape in apelist:
    print("one of the apes is " + ape)

The output from the script does not print the ape names, instead it 
prints each letter in the file. For example:

one of the apes is a
one of the apes is p
one of the apes is e

What should I do instead to get something like

one of the apes is Home sapiens
one of the apes is Pan troglodytes
one of the apes is Gorilla gorilla


More information about the Python-list mailing list