I have been running the following code o Jupyter Notebook 5.7.4 with Python 3.7.1. It worked fine there. When I tried to run the same code on HPC with python 3.5.2 I keep getting following error. if array[i-1] == array[i]: IndexError: list index out of range
import vcf
v = vcf.Reader(filename='/scratch/global/kkdesi01/Equine/animals/Chr/Chr11_possibleIntrogressionTargets.vcf')
f = open('/scratch/global/kkdesi01/Equine/animals/Chr/position11.txt', 'w+')
for record in v:
    f.write(str(record.POS))
    f.write('\n')
f.close()
with open('/scratch/global/kkdesi01/Equine/animals/Chr/position11.txt', 'r') as ins:
    array = []
    for line in ins:
        array.append(line)
print(len(array))
f = open('/scratch/global/kkdesi01/Equine/animals/Chr/filter11.txt', 'w+')
for i in range (1, len(array)):
    val1 = int(array [i-1])
    val2 = int(array [i])
    diff = val2-val1
    if diff < 10:
        f.write (str(val1))
        f.write ('\n')
        f.write (str(val2))
        f.write ('\n')
f.close()
with open('/scratch/global/kkdesi01/Equine/animals/Chr/filter11.txt', 'r') as ins:
    array = []
    for line in ins:
        array.append(line)
len(array)
for i in range(1, len(array)):
    if array[i-1] == array[i]:
        del array[i]
error if array[i-1] == array[i]: IndexError: list index out of range
I need help in understanding what needs to be changed in the code
 
    