On 2011-11-10 09:26, lina wrote:
atoms=[]

def fetchonefiledata(infilename):
         for line in open(infilename,"r"):
                 parts=line.strip().split()
                 atoms=parts[2]
                 print(atoms[0])

First you define "atoms" as an empty list, but in the line

atoms = parts[2]

you are redefining it by assigning a string to it. Thus, at the end of the for-loop, only the last string is stored (in every iteration you overwrite the former value with a new one).

You probably want to append the values:

atoms.append(parts[2])

Bye, Andreas
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to