[{"data":1,"prerenderedAt":233},["ShallowReactive",2],{"tag-labels":3,"site-header":4,"article-python-function-changes-nothing-en":75},{},{"featuredPost":5,"navigations":29},{"id":6,"title":7,"title_id":8,"slug":9,"excerpt":10,"excerpt_id":11,"has_translation":12,"published_at":13,"reading_time":14,"hidden_from_listing":15,"tags":16,"thumbnail_image":21,"og_image":22,"series":23,"authors":28},110,"When You Pick a Framework Just to Look Different","Ketika Pilih Framework Cuma Biar Kelihatan Beda","ketika-pilih-framework-cuma-biar-kelihatan-beda","The last time you chose a new framework or library, was it because your problem needed that tool, or because it sounded cool and few people around you were using it? That question is uncomfortable. Technology decisions are often made for reasons that never appear in any technical document.","Terakhir kali kamu milih framework atau library baru, itu karena masalahmu butuh alat itu, atau karena alatnya kedengaran keren dan belum banyak yang pakai? Pertanyaan ini nggak enak dijawab. Soalnya keputusan teknologi sering diambil dengan alasan yang nggak pernah ditulis di dokumen teknis mana pun.",true,"2026-10-06T15:25:21.000Z",5,false,[17,18,19,20],"karier","framework","opini","pengalaman",null,"\u002Fog\u002Fketika-pilih-framework-cuma-biar-kelihatan-beda.png",{"id":24,"title":25,"title_id":26,"slug":27},9,"Articles","Artikel","all",[],[30,49,70],{"collection":31,"item":32},"series",{"__typename":31,"title":25,"title_id":26,"slug":27,"children_series":33},[34,38,42,46],{"title":35,"title_id":36,"slug":37},"Artificial Intelligence","Kecerdasan Artifisial","kecerdasan-artifisial",{"title":39,"title_id":40,"slug":41},"Programming Fundamentals","Konsep Dasar Pemrograman","konsep-dasar-pemrograman",{"title":43,"title_id":44,"slug":45},"Algorithms and Data Structures","Algoritma dan Struktur Data","algoritma-struktur-data",{"title":47,"title_id":47,"slug":48},"LLM Systems","llm-systems",{"collection":31,"item":50},{"__typename":31,"title":51,"title_id":51,"slug":52,"children_series":53},"Tutorial","tutorial",[54,58,62,66],{"title":55,"title_id":56,"slug":57},"Learning Python","Belajar Python","belajar-python",{"title":59,"title_id":60,"slug":61},"Learning Go","Belajar Golang","belajar-golang",{"title":63,"title_id":64,"slug":65},"Learning Java","Belajar Java","belajar-java",{"title":67,"title_id":68,"slug":69},"Learning Pascal","Belajar Pascal","belajar-pascal",{"collection":31,"item":71},{"__typename":31,"title":72,"title_id":72,"slug":73,"children_series":74},"Lab","lab",[],{"article":76,"renderedBody":104,"renderedTakeaway":105,"latestArticles":106,"toc":216},{"id":77,"title":78,"title_id":79,"slug":80,"excerpt":81,"excerpt_id":82,"has_translation":12,"published_at":83,"reading_time":84,"hidden_from_listing":12,"tags":85,"thumbnail_image":21,"og_image":90,"series":21,"authors":91,"seoTitle":98,"seoDescription":99,"body_locale":100,"available_locales":101,"body":103,"takeway":21,"prerequisite":21},165,"Why Does Your Python Function Change Nothing?","Kenapa Fungsi Python Tidak Mengubah Apa Pun?","python-function-changes-nothing","Three lines, three reasons the change disappears: a default list every call shares, a name rebound instead of a dict written, and a counter that is read but never set. All three look correct in review.","Tiga baris, tiga alasan perubahannya hilang: default list yang dipakai bersama semua panggilan, nama yang diikat ulang bukan dict yang ditulis, dan penghitung yang cuma dibaca tanpa pernah diisi. Ketiganya terlihat benar waktu dibaca.","2026-12-02T02:00:00.000Z",3,[86,87,88,89],"python","scope","variable","debugging","\u002Fog\u002Fpython-function-changes-nothing.png",[92],{"authors_id":93},{"id":94,"name":95,"slug":96,"role":97,"profile_picture":21},1,"Daffa Izzuddin","izzudd","Writer","Python: why the value never changes","Total stays 0 because `total = total + harga` rebinds a local name; the list is shared because a default is built once; the till stays 0 because the global is never written.","en",[100,102],"id","\nIn Python, `total = total + harga` rebinds the local name `total`. It does not write to the dict you passed in, so the caller still sees 0. The same mistake wears three costumes here: a default list that every call shares, a name rebound inside a function, and a module-level counter that is read but never set.\n\nEach block below is a complete file. Run it, then read the line that surprises you.\n\n## What does `total = total + harga` actually do?\n\n```python\npesanan = {\"total\": 0}\n\ndef tambah_item(pesanan, harga):\n    total = pesanan[\"total\"]\n    total = total + harga\n\ntambah_item(pesanan, 15000)\nprint(pesanan[\"total\"])\n```\n\n```plain\n$ python3 rebind.py\n0\n```\n\nInside the function, `total` is a new local binding. `pesanan[\"total\"]` is a lookup, it returns 0, and the sum goes into the local, which disappears when the function returns. Writing back is a different operation: `pesanan[\"total\"] = pesanan[\"total\"] + harga` mutates the dict. Mutation is the only thing the caller can see.\n\n## Why do all the receipts hold the same items?\n\n```python\ndef pesanan_baru(meja, item=[]):\n    return {\"meja\": meja, \"item\": item}\n\nmeja1 = pesanan_baru(1)\nmeja3 = pesanan_baru(3)\nmeja1[\"item\"].append(\"kopi\")\nprint(meja1[\"item\"], meja3[\"item\"])\nprint(meja1[\"item\"] is meja3[\"item\"])\n```\n\n```plain\n$ python3 shared.py\n['kopi'] ['kopi']\nTrue\n```\n\nA default argument is evaluated once, when the `def` runs, not at every call. The list is built once, and every call that omits `item` receives that same object — so appending at table 1 appends at table 3. A default of `None` with the list created inside the function is the fix, and it is the only one that survives the next reader.\n\n## Why is the daily till still zero?\n\n```python\nTOTAL_KAS = 0\n\ndef catat_penjualan(jumlah):\n    total = TOTAL_KAS + jumlah\n    return total\n\ncatat_penjualan(15000)\nprint(TOTAL_KAS)\n```\n\n```plain\n$ python3 till.py\n0\n```\n\n`total` is local here too, because nothing in the function assigns to the module name. The global is read, the sum is returned, and the caller drops it. Either declare `global TOTAL_KAS` and assign, or return the new value and let the caller write it — the second is easier to test, because the function stops owning state it does not need.\n\n## What do the three fixes look like together?\n\n```python\ndef pesanan_baru(meja, item=None):\n    if item is None:\n        item = []\n    return {\"meja\": meja, \"item\": item, \"total\": 0}\n\ndef tambah_item(pesanan, nama, qty=1):\n    harga = MENU[nama]\n    pesanan[\"item\"].append({\"nama\": nama, \"qty\": qty, \"harga\": harga})\n    pesanan[\"total\"] = pesanan[\"total\"] + harga * qty\n    catat_penjualan(harga * qty)\n    return pesanan\n\ndef catat_penjualan(jumlah):\n    global TOTAL_KAS\n    TOTAL_KAS = TOTAL_KAS + jumlah\n    return TOTAL_KAS\n```\n\n```plain\n$ make check | grep LULUS\n[LULUS] 1. tiap nota cuma punya isi pesanan meja itu\n  [LULUS] 2. total nota dihitung dari itemnya\n  [LULUS] 3. kas harian bertambah sebesar penjualannya\n\n$ make demo | grep -E 'total nota|Kas harian'\nmeja 1  total nota: Rp30.000\n  meja 3  total nota: Rp8.000\n  meja 5  total nota: Rp12.000\nKas harian: Rp50.000\n```\n\n## When is rebinding the right thing?\n\nWhenever the value stays inside the function. `total = total + harga` is correct if the next line returns or prints `total` — the bug is only that the caller expected the dict to change. The test is who owns the value after the call: if nobody outside needs it, rebinding is cheaper than a parameter object and easier to read.\n\nWhat bites is the distance between the name you read and the object you actually change. Same syntax, two different results, and nothing on the line tells you which one you got.\n\nThree receipts, three different totals, one till. The full story is [Every Receipt Holds the Same Order](\u002Fp\u002Ftiap-nota-isinya-pesanan-yang-sama), the walkthrough answer is [The Default Value Is Only Created Once](\u002Fp\u002Fjawaban-nilai-default-cuma-dibuat-sekali), and the code is [inva-lab 0004](https:\u002F\u002Fgithub.com\u002Fizzudd\u002Finva-lab\u002Ftree\u002Fmain\u002F0004.mutation-and-scope).\n\nThe rule worth keeping: before you write an assignment, ask which object you are changing. If the answer is \"the name\", the caller will never see it.\n","\u003Cp>In Python, \u003Ccode>total = total + harga\u003C\u002Fcode> rebinds the local name \u003Ccode>total\u003C\u002Fcode>. It does not write to the dict you passed in, so the caller still sees 0. The same mistake wears three costumes here: a default list that every call shares, a name rebound inside a function, and a module-level counter that is read but never set.\u003C\u002Fp>\n\u003Cp>Each block below is a complete file. Run it, then read the line that surprises you.\u003C\u002Fp>\n\u003Ch2 id=\"what-does-total-total-harga-actually-do\">What does \u003Ccode>total = total + harga\u003C\u002Fcode> actually do?\u003C\u002Fh2>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">PYTHON\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"pesanan%20%3D%20%7B%22total%22%3A%200%7D%0A%0Adef%20tambah_item(pesanan%2C%20harga)%3A%0A%20%20%20%20total%20%3D%20pesanan%5B%22total%22%5D%0A%20%20%20%20total%20%3D%20total%20%2B%20harga%0A%0Atambah_item(pesanan%2C%2015000)%0Aprint(pesanan%5B%22total%22%5D)\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">pesanan \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> {\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"total\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">: \u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">0\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">def\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> tambah_item\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(pesanan, harga):\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    total \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> pesanan[\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"total\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">]\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    total \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> total \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">+\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> harga\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">tambah_item(pesanan, \u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">15000\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#79B8FF\">print\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(pesanan[\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"total\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">])\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20python3%20rebind.py%0A0\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ python3 rebind.py\u003C\u002Fspan>\n0\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>Inside the function, \u003Ccode>total\u003C\u002Fcode> is a new local binding. \u003Ccode>pesanan[&quot;total&quot;]\u003C\u002Fcode> is a lookup, it returns 0, and the sum goes into the local, which disappears when the function returns. Writing back is a different operation: \u003Ccode>pesanan[&quot;total&quot;] = pesanan[&quot;total&quot;] + harga\u003C\u002Fcode> mutates the dict. Mutation is the only thing the caller can see.\u003C\u002Fp>\n\u003Ch2 id=\"why-do-all-the-receipts-hold-the-same-items\">Why do all the receipts hold the same items?\u003C\u002Fh2>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">PYTHON\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"def%20pesanan_baru(meja%2C%20item%3D%5B%5D)%3A%0A%20%20%20%20return%20%7B%22meja%22%3A%20meja%2C%20%22item%22%3A%20item%7D%0A%0Ameja1%20%3D%20pesanan_baru(1)%0Ameja3%20%3D%20pesanan_baru(3)%0Ameja1%5B%22item%22%5D.append(%22kopi%22)%0Aprint(meja1%5B%22item%22%5D%2C%20meja3%5B%22item%22%5D)%0Aprint(meja1%5B%22item%22%5D%20is%20meja3%5B%22item%22%5D)\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">def\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> pesanan_baru\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(meja, item\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">[]):\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    return\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> {\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"meja\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">: meja, \u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"item\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">: item}\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">meja1 \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> pesanan_baru(\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">1\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">meja3 \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> pesanan_baru(\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">3\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">meja1[\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"item\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">].append(\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"kopi\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#79B8FF\">print\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(meja1[\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"item\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">], meja3[\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"item\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">])\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#79B8FF\">print\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(meja1[\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"item\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">] \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">is\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> meja3[\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"item\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">])\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20python3%20shared.py%0A%5B'kopi'%5D%20%5B'kopi'%5D%0ATrue\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ python3 shared.py\u003C\u002Fspan>\n['kopi'] ['kopi']\nTrue\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>A default argument is evaluated once, when the \u003Ccode>def\u003C\u002Fcode> runs, not at every call. The list is built once, and every call that omits \u003Ccode>item\u003C\u002Fcode> receives that same object — so appending at table 1 appends at table 3. A default of \u003Ccode>None\u003C\u002Fcode> with the list created inside the function is the fix, and it is the only one that survives the next reader.\u003C\u002Fp>\n\u003Ch2 id=\"why-is-the-daily-till-still-zero\">Why is the daily till still zero?\u003C\u002Fh2>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">PYTHON\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"TOTAL_KAS%20%3D%200%0A%0Adef%20catat_penjualan(jumlah)%3A%0A%20%20%20%20total%20%3D%20TOTAL_KAS%20%2B%20jumlah%0A%20%20%20%20return%20total%0A%0Acatat_penjualan(15000)%0Aprint(TOTAL_KAS)\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"color:#79B8FF\">TOTAL_KAS\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> =\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> 0\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">def\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> catat_penjualan\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(jumlah):\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    total \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> TOTAL_KAS\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> +\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> jumlah\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    return\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> total\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">catat_penjualan(\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">15000\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#79B8FF\">print\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">TOTAL_KAS\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20python3%20till.py%0A0\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ python3 till.py\u003C\u002Fspan>\n0\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Cp>\u003Ccode>total\u003C\u002Fcode> is local here too, because nothing in the function assigns to the module name. The global is read, the sum is returned, and the caller drops it. Either declare \u003Ccode>global TOTAL_KAS\u003C\u002Fcode> and assign, or return the new value and let the caller write it — the second is easier to test, because the function stops owning state it does not need.\u003C\u002Fp>\n\u003Ch2 id=\"what-do-the-three-fixes-look-like-together\">What do the three fixes look like together?\u003C\u002Fh2>\n\n\u003Cdiv class=\"code-block-wrapper my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden bg-[#24292e] text-[#e1e4e8] transition-all\">\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ff5f56] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#ffbd2e] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"w-3 h-3 rounded-full bg-[#27c93f] border border-black\u002F40 inline-block\">\u003C\u002Fspan>\n      \u003Cspan class=\"ml-2 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">PYTHON\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"def%20pesanan_baru(meja%2C%20item%3DNone)%3A%0A%20%20%20%20if%20item%20is%20None%3A%0A%20%20%20%20%20%20%20%20item%20%3D%20%5B%5D%0A%20%20%20%20return%20%7B%22meja%22%3A%20meja%2C%20%22item%22%3A%20item%2C%20%22total%22%3A%200%7D%0A%0Adef%20tambah_item(pesanan%2C%20nama%2C%20qty%3D1)%3A%0A%20%20%20%20harga%20%3D%20MENU%5Bnama%5D%0A%20%20%20%20pesanan%5B%22item%22%5D.append(%7B%22nama%22%3A%20nama%2C%20%22qty%22%3A%20qty%2C%20%22harga%22%3A%20harga%7D)%0A%20%20%20%20pesanan%5B%22total%22%5D%20%3D%20pesanan%5B%22total%22%5D%20%2B%20harga%20*%20qty%0A%20%20%20%20catat_penjualan(harga%20*%20qty)%0A%20%20%20%20return%20pesanan%0A%0Adef%20catat_penjualan(jumlah)%3A%0A%20%20%20%20global%20TOTAL_KAS%0A%20%20%20%20TOTAL_KAS%20%3D%20TOTAL_KAS%20%2B%20jumlah%0A%20%20%20%20return%20TOTAL_KAS\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed bg-[#24292e]\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">def\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> pesanan_baru\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(meja, item\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">None\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">):\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    if\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> item \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">is\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> None\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">:\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">        item \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> []\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    return\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> {\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"meja\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">: meja, \u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"item\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">: item, \u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"total\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">: \u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">0\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">def\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> tambah_item\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(pesanan, nama, qty\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\">1\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">):\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    harga \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> MENU\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">[nama]\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    pesanan[\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"item\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">].append({\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"nama\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">: nama, \u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"qty\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">: qty, \u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"harga\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">: harga})\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    pesanan[\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"total\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">] \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> pesanan[\u003C\u002Fspan>\u003Cspan style=\"color:#9ECBFF\">\"total\"\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">] \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">+\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> harga \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">*\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> qty\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#E1E4E8\">    catat_penjualan(harga \u003C\u002Fspan>\u003Cspan style=\"color:#F97583\">*\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> qty)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    return\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> pesanan\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">def\u003C\u002Fspan>\u003Cspan style=\"color:#B392F0\"> catat_penjualan\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\">(jumlah):\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    global\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> TOTAL_KAS\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#79B8FF\">    TOTAL_KAS\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> =\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> TOTAL_KAS\u003C\u002Fspan>\u003Cspan style=\"color:#F97583\"> +\u003C\u002Fspan>\u003Cspan style=\"color:#E1E4E8\"> jumlah\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"color:#F97583\">    return\u003C\u002Fspan>\u003Cspan style=\"color:#79B8FF\"> TOTAL_KAS\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003Cdiv class=\"code-block-wrapper code-output my-6 not-prose rounded-xl border-2 border-black dark:border-gray-600 shadow-neo overflow-hidden text-[#e1e4e8] transition-all\" data-output-block>\n  \u003Cdiv class=\"code-block-header flex items-center justify-between px-4 py-2.5 bg-[#1f2428] border-b-2 border-black dark:border-gray-600 font-mono text-xs font-bold text-gray-300 select-none\">\n    \u003Cdiv class=\"flex items-center gap-2\">\n      \u003Cspan class=\"code-output-mark\" aria-hidden=\"true\">&gt;_\u003C\u002Fspan>\n      \u003Cspan class=\"ml-1 font-mono font-bold text-xs uppercase tracking-wider text-gray-300\">Output\u003C\u002Fspan>\n    \u003C\u002Fdiv>\n    \u003Cbutton type=\"button\" class=\"copy-code-btn flex items-center gap-1.5 px-3 py-1 text-xs font-bold bg-[#2f363d] text-gray-200 border-2 border-black dark:border-gray-500 rounded-lg shadow-neo-sm hover:translate-x-0.5 hover:translate-y-0.5 hover:shadow-none hover:bg-gray-700 transition-all cursor-pointer\" data-code=\"%24%20make%20check%20%7C%20grep%20LULUS%0A%5BLULUS%5D%201.%20tiap%20nota%20cuma%20punya%20isi%20pesanan%20meja%20itu%0A%20%20%5BLULUS%5D%202.%20total%20nota%20dihitung%20dari%20itemnya%0A%20%20%5BLULUS%5D%203.%20kas%20harian%20bertambah%20sebesar%20penjualannya%0A%0A%24%20make%20demo%20%7C%20grep%20-E%20'total%20nota%7CKas%20harian'%0Ameja%201%20%20total%20nota%3A%20Rp30.000%0A%20%20meja%203%20%20total%20nota%3A%20Rp8.000%0A%20%20meja%205%20%20total%20nota%3A%20Rp12.000%0AKas%20harian%3A%20Rp50.000\" title=\"Copy\">\n      \u003Csvg class=\"w-3.5 h-3.5 copy-icon-svg\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n        \u003Cpath stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\">\u003C\u002Fpath>\n      \u003C\u002Fsvg>\n      \u003Cspan class=\"copy-text\">Copy\u003C\u002Fspan>\n    \u003C\u002Fbutton>\n  \u003C\u002Fdiv>\n  \u003Cdiv class=\"code-block-content p-4 overflow-x-auto text-sm font-mono leading-relaxed\">\n    \u003Cpre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\">\u003Ccode>\u003Cspan class=\"code-output-cmd\">$ make check | grep LULUS\u003C\u002Fspan>\n[LULUS] 1. tiap nota cuma punya isi pesanan meja itu\n  [LULUS] 2. total nota dihitung dari itemnya\n  [LULUS] 3. kas harian bertambah sebesar penjualannya\n\n\u003Cspan class=\"code-output-cmd\">$ make demo | grep -E 'total nota|Kas harian'\u003C\u002Fspan>\nmeja 1  total nota: Rp30.000\n  meja 3  total nota: Rp8.000\n  meja 5  total nota: Rp12.000\nKas harian: Rp50.000\u003C\u002Fcode>\u003C\u002Fpre>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\u003Ch2 id=\"when-is-rebinding-the-right-thing\">When is rebinding the right thing?\u003C\u002Fh2>\n\u003Cp>Whenever the value stays inside the function. \u003Ccode>total = total + harga\u003C\u002Fcode> is correct if the next line returns or prints \u003Ccode>total\u003C\u002Fcode> — the bug is only that the caller expected the dict to change. The test is who owns the value after the call: if nobody outside needs it, rebinding is cheaper than a parameter object and easier to read.\u003C\u002Fp>\n\u003Cp>What bites is the distance between the name you read and the object you actually change. Same syntax, two different results, and nothing on the line tells you which one you got.\u003C\u002Fp>\n\u003Cp>Three receipts, three different totals, one till. The full story is \u003Ca href=\"\u002Fp\u002Ftiap-nota-isinya-pesanan-yang-sama\">Every Receipt Holds the Same Order\u003C\u002Fa>, the walkthrough answer is \u003Ca href=\"\u002Fp\u002Fjawaban-nilai-default-cuma-dibuat-sekali\">The Default Value Is Only Created Once\u003C\u002Fa>, and the code is \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fizzudd\u002Finva-lab\u002Ftree\u002Fmain\u002F0004.mutation-and-scope\">inva-lab 0004\u003C\u002Fa>.\u003C\u002Fp>\n\u003Cp>The rule worth keeping: before you write an assignment, ask which object you are changing. If the answer is &quot;the name&quot;, the caller will never see it.\u003C\u002Fp>\n","",[107,125,140,158,179,199],{"id":108,"title":109,"title_id":110,"slug":111,"excerpt":112,"excerpt_id":113,"has_translation":12,"published_at":114,"reading_time":14,"hidden_from_listing":15,"tags":115,"thumbnail_image":21,"og_image":119,"series":120,"authors":122},152,"Every Write Comes Back as News","Tiap Write Balik ke Kamu sebagai Kabar Baru","every-write-comes-back-as-news","A supplier file says the mug is gone, the app drafts it, the store puts it back, forty times. Seven checks, and the eager webhook handler is only the second problem.","File supplier bilang mug-nya habis, app bikin draft, store mengembalikannya, 40 kali. Tujuh pemeriksaan, handler webhook yang sigap cuma masalah kedua.","2026-12-01T01:00:00.000Z",[116,117,118,73],"webhook","event-driven","distributed-systems","\u002Fog\u002Fevery-write-comes-back-as-news.png",{"id":121,"title":72,"title_id":72,"slug":73},29,[123],{"authors_id":124},{"id":94,"name":95,"slug":96,"role":97,"profile_picture":21},{"id":126,"title":127,"title_id":128,"slug":129,"excerpt":130,"excerpt_id":131,"has_translation":12,"published_at":114,"reading_time":132,"hidden_from_listing":15,"tags":133,"thumbnail_image":21,"og_image":135,"series":136,"authors":137},151,"The Status That Changed Itself","Status yang Mengubah Dirinya Sendiri","the-status-that-changed-itself","A product's status blinks between published and draft, nothing errors, and the guard you wrote first works right up until it doesn't. The loop was never an echo.","Status produk berkedip antara published dan draft, tidak ada yang error, dan penjaga pertamamu jalan sampai akhirnya tidak. Loop-nya bukan gema.",4,[116,117,118,134],"post-mortem","\u002Fog\u002Fthe-status-that-changed-itself.png",{"id":24,"title":25,"title_id":26,"slug":27},[138],{"authors_id":139},{"id":94,"name":95,"slug":96,"role":97,"profile_picture":21},{"id":141,"title":142,"title_id":143,"slug":144,"excerpt":145,"excerpt_id":146,"has_translation":12,"published_at":147,"reading_time":148,"hidden_from_listing":15,"tags":149,"thumbnail_image":21,"og_image":152,"series":153,"authors":155},164,"Python Capstone: Why a Blank CSV Field Cut the Class Average","Python Capstone: Kenapa Satu Kolom CSV Kosong Memotong Rata-rata Kelas","python-capstone-gradebook","A gradebook reads four students and writes a JSON report. The class average says 52.42, because two empty fields became zeros.","Buku nilai membaca empat siswa dan menulis laporan JSON. Rata-rata kelasnya bilang 52.42, karena dua kolom kosong berubah jadi nol.","2026-11-21T01:00:00.000Z",8,[86,150,151],"input-output","cli","\u002Fog\u002Fpython-capstone-gradebook.png",{"id":154,"title":55,"title_id":56,"slug":57},10,[156],{"authors_id":157},{"id":94,"name":95,"slug":96,"role":97,"profile_picture":21},{"id":159,"title":160,"title_id":161,"slug":162,"excerpt":163,"excerpt_id":164,"has_translation":12,"published_at":147,"reading_time":132,"hidden_from_listing":15,"tags":165,"thumbnail_image":21,"og_image":170,"series":171,"authors":176},48,"What a Linked List Actually Is","Tentang Struktur Data LinkedList","tentang-struktur-data-linked-list","A linked list is a linear chain of nodes, each holding data and a pointer to the next node. Here is what that chain looks like, what it costs next to an array, and the same minimal implementation in Java, Python, and JavaScript.","Linked list adalah rantai linear berisi node, dan setiap node menyimpan data plus pointer ke node berikutnya. Ini bentuk rantainya, ongkosnya dibanding array, dan implementasi paling sederhana dalam Java, Python, serta JavaScript.",[166,167,168,169],"struktur-data","linked-list","pointer","konsep","\u002Fog\u002Ftentang-struktur-data-linked-list.png",{"id":172,"title":173,"title_id":174,"slug":175},28,"Linear Data Structures","Struktur Data Linear","asd-struktur-linear",[177],{"authors_id":178},{"id":94,"name":95,"slug":96,"role":97,"profile_picture":21},{"id":180,"title":181,"title_id":182,"slug":183,"excerpt":184,"excerpt_id":185,"has_translation":12,"published_at":186,"reading_time":187,"hidden_from_listing":15,"tags":188,"thumbnail_image":21,"og_image":193,"series":194,"authors":196},163,"Pascal Capstone: Why Every Gradebook Score Came Back Zero","Capstone Pascal: Kenapa Semua Skor Buku Nilai Kembali Nol","pascal-gradebook-capstone","A gradebook reads three students from a file, prints three rows, and every score is 0. The procedure filled a copy of the array, because the parameter was missing `var`. Add the word and the report matches the file; the compiler had already warned about the call that filled nothing.","Sebuah buku nilai membaca tiga siswa dari berkas, mencetak tiga baris, dan setiap skornya 0. Prosedurnya mengisi salinan array, karena parameternya kehilangan `var`. Tambahkan kata itu dan laporannya cocok dengan berkasnya; kompilator sudah memperingatkan soal pemanggilan yang tidak mengisi apa pun.","2026-11-20T01:00:00.000Z",6,[189,190,191,192],"pascal","record","array","prosedur","\u002Fog\u002Fpascal-gradebook-capstone.png",{"id":195,"title":67,"title_id":68,"slug":69},14,[197],{"authors_id":198},{"id":94,"name":95,"slug":96,"role":97,"profile_picture":21},{"id":200,"title":201,"title_id":202,"slug":203,"excerpt":204,"excerpt_id":205,"has_translation":12,"published_at":186,"reading_time":187,"hidden_from_listing":15,"tags":206,"thumbnail_image":21,"og_image":207,"series":208,"authors":213},162,"Python File I\u002FO: Why the Second Read Came Back Empty","Python File I\u002FO: Kenapa Pembacaan Kedua Kembali Kosong","python-file-read-write","A notes script saves a line, prints it back, then counts zero. The file on disk is correct: `read()` left the pointer at the end, so the second call returned an empty string. Read once into a variable, or `seek(0)`, and the count matches the file.","Skrip catatan menyimpan satu baris, mencetaknya kembali, lalu menghitung nol. Berkas di disk sudah benar: `read()` meninggalkan pointer di ujung, jadi panggilan kedua mengembalikan string kosong. Baca sekali ke sebuah variabel, atau `seek(0)`, dan hitungannya cocok dengan berkas.",[86,150],"\u002Fog\u002Fpython-file-read-write.png",{"id":209,"title":210,"title_id":211,"slug":212},18,"Working with Python Scripts","Menggunakan Script Python","python-pemrograman-dengan-script",[214],{"authors_id":215},{"id":94,"name":95,"slug":96,"role":97,"profile_picture":21},[217,221,224,227,230],{"text":218,"depth":219,"id":220},"What does total = total + harga actually do?",2,"what-does-total-total-harga-actually-do",{"text":222,"depth":219,"id":223},"Why do all the receipts hold the same items?","why-do-all-the-receipts-hold-the-same-items",{"text":225,"depth":219,"id":226},"Why is the daily till still zero?","why-is-the-daily-till-still-zero",{"text":228,"depth":219,"id":229},"What do the three fixes look like together?","what-do-the-three-fixes-look-like-together",{"text":231,"depth":219,"id":232},"When is rebinding the right thing?","when-is-rebinding-the-right-thing",1796193146697]