import mathOK = Truetest = 1openFile = open(numbers, r)sir = []for val in openFile.read().split():    sir.append(int(val))    test += 1    if test > 2:        if math.gcd(sir[test-3], sir[test-2]) > 1:            OK = FalseopenFile.close()print(OK)This program need to print True, if the GCD of all numbers in that sequence is 1, false if it isn't. Is there an efficient way to make the code shorter?
Testing whether numbers are relatively prime
python;beginner
So at the bottom you will find a more Pythonic version of your code, with all of its bugs still intact. The changes made include:Use a context manager for filesThis construct:with open(file1, r) as f:allows the removal of f.close() and is just generally more robust.Lists know how long they areI removed the unneeded test variable and simply use something like sir[-x] to reference elements from the end of the list.  This allows changing:gcd(sir[test-3], sir[test-2])to the equivalent:gcd(*sir[-2:])This also removes the off by one error in test.  So I guess this review did fix a bug.Break from loop as soon as possibleOnce you have your answer, there is no point in continuing a loop.Restructure to lower number of tests neededBy starting the loop with sir=[1] instead of an empty list, the list is long enough to test for gcd in the first loop, and thus a length check is not needed.Full Listingimport mathOK = Truesir = [1]with open(file1, r) as f:    for val in f.read().split():        sir.append(int(val))        if math.gcd(*sir[-2:]) > 1:            OK = False            breakprint(OK, sir)