Add a scalar product to the example list comprehensions based on a suggestion

sent to python-docs.
This commit is contained in:
Fred Drake 2001-12-03 18:54:33 +00:00
parent f4c20d354c
commit 1da50f6c6e

View 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}