Alright, So I am rather new to programming and Python and I had a couple of questions that maybe you guys could help me with...
I currently have a .txt that when read in Python is a list, now i want to be able to split it up into seperate components so that i can put them all in a dictionary. I want to be able to up one part of the line and have it give me another part (obviously the purpose of having it as a dictionary).
a sample line from the file:
1 hydrogen H 1.0079
So if i were to say
>>>Print weight
1.0079
Here is a partial look at the code that I was attempting to write:
def make_atomic_weights_dict(data_lines):
d = {}
for data_line in data_lines:
parts = data_line.split()
d'[parts[3]] = float.parts [4]' # these will be added to dictionary
if len(parts) == 4:
print float.parts[4]
else print 0 '%s does not have a well defined atomic weight.' % s(parts[3])
Thanks a bunch