From ca77718ecebf9e2cd8da31849d373a222e79f8ee Mon Sep 17 00:00:00 2001 From: gahjelle Date: Sun, 2 Feb 2025 13:38:32 +0100 Subject: [PATCH] Final QA --- python-for-loop/README.md | 2 +- python-for-loop/chained_lists.py | 8 ++++++++ python-for-loop/dictionaries.py | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 python-for-loop/chained_lists.py diff --git a/python-for-loop/README.md b/python-for-loop/README.md index 4cfec1206a..35616cff20 100644 --- a/python-for-loop/README.md +++ b/python-for-loop/README.md @@ -1,3 +1,3 @@ # Python for Loops: The Pythonic Way -This folder provides the code examples for the Real Python tutorial [Python for Loops: The Pythonic Way](https://realpython.com/python-for-loop-update/). +This folder provides the code examples for the Real Python tutorial [Python for Loops: The Pythonic Way](https://realpython.com/python-for-loop/). diff --git a/python-for-loop/chained_lists.py b/python-for-loop/chained_lists.py new file mode 100644 index 0000000000..5465e0a99a --- /dev/null +++ b/python-for-loop/chained_lists.py @@ -0,0 +1,8 @@ +from itertools import chain + +first = [7, 6, 1] +second = [4, 1] +third = [8, 0, 6] + +for value in chain(first, second, third): + print(value**2) diff --git a/python-for-loop/dictionaries.py b/python-for-loop/dictionaries.py index 80c1dc3494..fb91cb8c8f 100644 --- a/python-for-loop/dictionaries.py +++ b/python-for-loop/dictionaries.py @@ -25,5 +25,5 @@ for team in teams.values(): print(team) -for city, team in teams.items(): - print(city, "->", team) +for place, team in teams.items(): + print(place, "->", team)