title: Generating unique, ordered Pythagorean triplets
body: <p>This is a program I wrote to calculate Pythagorean triplets. When I run the program it prints each set of triplets twice because of the if statement. Is there any way I can tell the program to only print a new set of triplets once? Thanks.</p>
  
  <pre><code>import math
  
  def main():
      for x in range (1, 1000):
          for y in range (1, 1000):
              for z in range(1, 1000):
                  if x*x == y*y + z*z:
                      print y, z, x
                      print '-'*50
  
  if __name__ == '__main__':
      main()  
  </code></pre>