Jump to content

List comprehensions: Difference between revisions

m
→‎{{header|Python}}: make it actually work/be runnable (on 2.7)
m (→‎{{header|Python}}: experimental edit)
m (→‎{{header|Python}}: make it actually work/be runnable (on 2.7))
Line 1,936:
=={{header|Python}}==
<syntaxhighlight lang="python">
import itertools
n = 20
 
# List comprehension:
[(x,y,z) for x in xrange(1,n+1) for y in xrange(x,n+1) for z in xrange(y,n+1) if x**2 + y**2 == z**2]
7,820

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.