]> granicus.if.org Git - python/commitdiff
Add a scalar product to the example list comprehensions based on a suggestion
authorFred Drake <fdrake@acm.org>
Mon, 3 Dec 2001 18:54:33 +0000 (18:54 +0000)
committerFred Drake <fdrake@acm.org>
Mon, 3 Dec 2001 18:54:33 +0000 (18:54 +0000)
sent to python-docs.

Doc/tut/tut.tex

index 387b53c2be26c069561f5de9eaf4231a0dd8b670..dfa71fe2d8196e711ad40db554dbede5e23a5a5a 100644 (file)
@@ -1846,6 +1846,8 @@ SyntaxError: invalid syntax
 [8, 6, -18, 16, 12, -36, 24, 18, -54]
 >>> [x+y for x in vec1 for y in vec2]
 [6, 5, -7, 8, 7, -5, 10, 9, -3]
+>>> [vec1[i]*vec2[i] for i in range(len(vec1))]
+[8, 12, -54]
 \end{verbatim}