From 0c76dc11d7681874e7607d362ccff0c9742f208b Mon Sep 17 00:00:00 2001 From: Olli Graf Date: Wed, 19 Jun 2024 12:03:53 +0200 Subject: [PATCH] Versuche mit Assignment Expressions. --- walross/loop.py | 10 ++++++++++ walross/simple_loop.py | 10 ++++++++++ 2 files changed, 20 insertions(+) create mode 100644 walross/loop.py create mode 100644 walross/simple_loop.py diff --git a/walross/loop.py b/walross/loop.py new file mode 100644 index 0000000..da719f6 --- /dev/null +++ b/walross/loop.py @@ -0,0 +1,10 @@ +# Ohne Walross-Operator +n = 0 +while n < 10: + n += 1 + print(n) + +# Mit Walross-Operator +n = 0 +while (n := n + 1) <= 10: + print(n) diff --git a/walross/simple_loop.py b/walross/simple_loop.py new file mode 100644 index 0000000..5d67a91 --- /dev/null +++ b/walross/simple_loop.py @@ -0,0 +1,10 @@ +# Ohne Walross-Operator +n = 0 +while n < 10: + n += 1 + print(n) + +# Mit Walross-Operator +n = 0 +while (n := n + 1) < 10: + print(n)