mirror of
https://github.com/python/cpython.git
synced 2025-11-25 12:44:13 +00:00
Add a scalar product to the example list comprehensions based on a suggestion
sent to python-docs.
This commit is contained in:
parent
f4c20d354c
commit
1da50f6c6e
1 changed files with 2 additions and 0 deletions
|
|
@ -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}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue