From f21d38e6e1a1c240fdfeb005aaf6f2bae8f05761 Mon Sep 17 00:00:00 2001 From: Martin Mares <mj@ucw.cz> Date: Fri, 15 Nov 2019 10:35:27 +0100 Subject: [PATCH] =?UTF-8?q?07:=20P=C5=99=C3=ADklad=20na=20zip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 07-compr/07-compr.tex | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/07-compr/07-compr.tex b/07-compr/07-compr.tex index 496d437..2e47c89 100644 --- a/07-compr/07-compr.tex +++ b/07-compr/07-compr.tex @@ -75,6 +75,29 @@ b \cmt{(přiřazení každého prvku n-tice/seznamu zvlášť)} % ---------------------------------------------------------------------- +\begin{frame}{Příklad: Zipování seznamů} + +\py{% +x = [1, 2, 3]\\ +y = ["a", "b", "c"]\\ +list(zip(x, y)) +}{% +[(1, 'a'), (2, 'b'), (3, 'c')] +} + +\py{% +for i, j in zip(x, y):\\ +\>print(i, j) +}{% +1 a\\ +2 b\\ +3 c +} + +\end{frame} + +% ---------------------------------------------------------------------- + \begin{frame}{List comprehension} \py{% -- GitLab