From 700f8d7605b823accd293f51c2bed53438ac22ac Mon Sep 17 00:00:00 2001 From: George Halkiadakis Date: Fri, 17 Mar 2023 03:38:29 +0200 Subject: Initial commit --- code-examples.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 code-examples.py (limited to 'code-examples.py') diff --git a/code-examples.py b/code-examples.py new file mode 100644 index 0000000..d8d0042 --- /dev/null +++ b/code-examples.py @@ -0,0 +1,24 @@ +# test +a = 1 +b = 4 + +def addto(x, l) : + l.append({ + "n" : x, + "c": [] + }) + for it in l : + if it["n"] == 4 : + subl = it["c"] + subl.append(x) + it['c'] = subl + + +malist = [] + +malist.append({ "n" : a }) +print(malist) + +addto(b, malist) +addto(b, malist) +print(malist) -- cgit v1.2.3