HETATM 1 H HOH A 1 27.265 36.739 58.126
HETATM 2 H HOH A 1 27.109 35.124 57.944
HETATM 3 O HOH A 1 27.486 35.958 57.542
...
HETATM 9999 O HOH A3333 30.490 83.899 10.929
END
IndexError: list index out of range
water = open('watercube.pdb','r+')
water2 = water.readlines()
for col in water2:
el = [col.split()[1] for col in water2]
water2=['HETATM 1 H HOH A 1 27.265 36.739 58.126',
'HETATM 2 H HOH A 1 27.109 35.124 57.944',
'HETATM 3 O HOH A 1 27.486 35.958 57.542']
for col in water2:
el = [col.split() for col in water2]
print (el)
[['HETATM', '1', 'H', 'HOH', 'A', '1', '27.265', '36.739', '58.126'],
['HETATM', '2', 'H', 'HOH', 'A', '1', '27.109', '35.124', '57.944'],
['HETATM', '3', 'O', 'HOH', 'A', '1', '27.486', '35.958', '57.542']]
water2=['HETATM 1 H HOH A 1 27.265 36.739 58.126',
'HETATM 2 H HOH A 1 27.109 35.124 57.944',
'HETATM 3 O HOH A 1 27.486 35.958 57.542']
el = [col.split() for col in water2]