I can find out Pythagorean triplets using for loop as follows:
def triplet(n): # Find all the Pythagorean triplets between 1 and n (inclusive) for a in range(n
I think you mean
[(a,b,c) for a in range(n+1) for b in range(a) for c in range(b) if a*a == b*b + c*c]
That at least is syntactically valid.