<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Harsh Thalwal</title>
    <description>The latest articles on DEV Community by Harsh Thalwal (@harsh_thalwal_d1262cc3a90).</description>
    <link>https://dev.to/harsh_thalwal_d1262cc3a90</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3530055%2Ffb9703d9-f937-4859-9ecf-bfce7c3e612d.png</url>
      <title>DEV Community: Harsh Thalwal</title>
      <link>https://dev.to/harsh_thalwal_d1262cc3a90</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/harsh_thalwal_d1262cc3a90"/>
    <language>en</language>
    <item>
      <title>I Built a 64-bit OS from Scratch in C and Assembly — No GRUB, No Shortcuts</title>
      <dc:creator>Harsh Thalwal</dc:creator>
      <pubDate>Thu, 28 May 2026 08:25:13 +0000</pubDate>
      <link>https://dev.to/harsh_thalwal_d1262cc3a90/i-built-a-64-bit-os-from-scratch-in-c-and-assembly-no-grub-no-shortcuts-6be</link>
      <guid>https://dev.to/harsh_thalwal_d1262cc3a90/i-built-a-64-bit-os-from-scratch-in-c-and-assembly-no-grub-no-shortcuts-6be</guid>
      <description>&lt;p&gt;Most people learn how operating systems work from textbooks.&lt;br&gt;
I decided to just build one.&lt;/p&gt;

&lt;p&gt;Not with GRUB. Not with UEFI abstractions. Just raw x86_64 Assembly, freestanding C, and a lot of time spent reading Intel manuals at 2am.&lt;/p&gt;

&lt;p&gt;This is the story of &lt;strong&gt;AxiomX-OS&lt;/strong&gt; — a fully custom x86_64 operating system I built from scratch, including its own 4-stage bootloader, physical and virtual memory manager, round-robin scheduler with context switching, and an interactive shell with 24 built-in commands.&lt;/p&gt;

&lt;p&gt;Here's what I built and how.&lt;/p&gt;


&lt;h2&gt;
  
  
  Why build an OS?
&lt;/h2&gt;

&lt;p&gt;"How does an OS actually work?" is one of those questions that deserves a real answer — not a textbook chapter, but actual code running on actual hardware.&lt;/p&gt;

&lt;p&gt;I wanted to understand what happens between pressing the power button and running a program. Every layer of abstraction people take for granted — memory, processes, interrupts — I wanted to build myself.&lt;/p&gt;

&lt;p&gt;So I did.&lt;/p&gt;


&lt;h2&gt;
  
  
  The Architecture: A Custom 4-Stage Bootloader
&lt;/h2&gt;

&lt;p&gt;Most hobby OS projects start with GRUB. I didn't want that. GRUB hides too much — I wanted to understand the full boot sequence from the very first instruction the CPU executes.&lt;/p&gt;

&lt;p&gt;AxiomX boots through 4 stages, all written in pure x86 Assembly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Stage 0  →  Stage 1  →  Stage 2  →  Stage 3  →  Kernel
 BIOS        Real         Protected    Long        64-bit C
 MBR         Mode         Mode         Mode        Entry
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Stage 0 (MBR):&lt;/strong&gt; The BIOS loads 512 bytes from sector 0 into memory at &lt;code&gt;0x7C00&lt;/code&gt;. That's your entire budget for the first stage — 512 bytes to set up the stack, load the next stage, and hand off control.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stage 1 (Real Mode):&lt;/strong&gt; Running in 16-bit real mode with access to BIOS interrupts. I use this stage to call the E820 BIOS interrupt to build a memory map of the system — which memory regions are usable, reserved, or ACPI-related. This data is critical for the physical memory manager later.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stage 2 (Protected Mode):&lt;/strong&gt; Sets up a Global Descriptor Table (GDT), enables the A20 line, and jumps into 32-bit protected mode. No more BIOS calls from here.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stage 3 (Long Mode):&lt;/strong&gt; Sets up page tables for identity mapping, enables PAE and long mode via MSRs, and finally jumps into 64-bit mode before handing off to the C kernel entry point.&lt;/p&gt;

&lt;p&gt;Writing this from scratch taught me more about x86 architecture than any textbook ever could.&lt;/p&gt;




&lt;h2&gt;
  
  
  Memory Management: PMM + VMM + Heap
&lt;/h2&gt;

&lt;p&gt;Once the kernel is running, the first thing it needs is memory management.&lt;/p&gt;

&lt;h3&gt;
  
  
  Physical Memory Manager (PMM)
&lt;/h3&gt;

&lt;p&gt;The PMM tracks which physical pages (4KB each) are free or used, using a &lt;strong&gt;bitmap allocator&lt;/strong&gt;. Each bit represents one 4KB page. Allocating memory is a matter of finding the first 0 bit, flipping it to 1, and returning that page's address.&lt;/p&gt;

&lt;p&gt;Simple in concept, but getting the bitmap correctly initialized from the E820 map — respecting reserved regions, kernel regions, and usable RAM — took careful work.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;[pmm] Initialised: 32736 total pages, 31967 free pages
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Virtual Memory Manager (VMM)
&lt;/h3&gt;

&lt;p&gt;The VMM implements x86_64 paging using a &lt;strong&gt;PML4 page table&lt;/strong&gt; structure with 2MB huge pages. Every virtual address goes through a 4-level page table walk before reaching physical memory.&lt;/p&gt;

&lt;p&gt;Setting up identity mapping for the first 128MB of memory means the kernel's virtual addresses match its physical addresses — which simplifies early kernel development enormously.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;[vmm] PML4 at 0x4000, 128MB identity-mapped
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Kernel Heap
&lt;/h3&gt;

&lt;p&gt;On top of the VMM sits a simple dynamic heap allocator — the kernel equivalent of &lt;code&gt;malloc&lt;/code&gt; and &lt;code&gt;free&lt;/code&gt;. Without this, the kernel can't dynamically allocate data structures at runtime.&lt;/p&gt;




&lt;h2&gt;
  
  
  Interrupts: IDT + PIT
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;Interrupt Descriptor Table (IDT)&lt;/strong&gt; tells the CPU what to do when an interrupt fires — whether it's a hardware timer, a keyboard press, or a CPU exception like a page fault.&lt;/p&gt;

&lt;p&gt;Setting up the IDT involves writing 256 entries, each pointing to an ISR (Interrupt Service Routine). The tricky part is that the CPU pushes different amounts of data onto the stack for different exceptions, so you need stub handlers in Assembly to normalize the stack before jumping into C.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;PIT (Programmable Interval Timer)&lt;/strong&gt; fires at 100 Hz — 100 times per second. Every tick is used by the scheduler to decide whether to switch tasks.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;[pit] Initialised at 100 Hz (divisor=11931)
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Scheduler: Round-Robin with Context Switching
&lt;/h2&gt;

&lt;p&gt;The scheduler is probably the most satisfying part to get working.&lt;/p&gt;

&lt;p&gt;AxiomX uses a &lt;strong&gt;round-robin scheduler&lt;/strong&gt; — each task gets a fixed quantum (10 ticks), and when the quantum expires, the PIT fires an interrupt and the scheduler picks the next task in the queue.&lt;/p&gt;

&lt;p&gt;The hard part is &lt;strong&gt;context switching&lt;/strong&gt; — saving the current task's CPU state (all registers, stack pointer, instruction pointer) and restoring the next task's state, all in Assembly, while making it transparent to both tasks.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;[sched] Initialised. Idle PID=0, quantum=10 ticks
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Watching three stress workers run simultaneously for the first time — each completing exactly 50,000 iterations and confirming round-robin — was genuinely one of the best moments of this project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;AxiomX-OS&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;stress
&lt;span class="go"&gt;  worker0 : 50000 iters
  worker1 : 50000 iters
  worker2 : 50000 iters
  Round-robin confirmed
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  The Shell: 24 Built-in Commands
&lt;/h2&gt;

&lt;p&gt;AxiomX drops into an interactive shell on boot, with 24 built-in commands including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;mem&lt;/code&gt; — live memory stats and usage bar&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ps&lt;/code&gt; — list processes and states&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;schedviz&lt;/code&gt; — visual scheduler state and timing&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;hexdump &amp;lt;addr&amp;gt;&lt;/code&gt; — hex dump memory at any address&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;virt2phys &amp;lt;addr&amp;gt;&lt;/code&gt; — walk page tables and translate virtual → physical address&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;regs&lt;/code&gt; — dump all CPU registers&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;stack&lt;/code&gt; — dump current stack + call frame chain&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;trace on|off&lt;/code&gt; — live kernel event tracing&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cpuinfo&lt;/code&gt; — CPU info via CPUID&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;vmmap&lt;/code&gt; — virtual memory layout&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;TAB autocomplete and UP/DOWN history navigation are also implemented.&lt;/p&gt;




&lt;h2&gt;
  
  
  What I Learned
&lt;/h2&gt;

&lt;p&gt;Building an OS from scratch teaches you things that no amount of high-level programming can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Nothing is magic.&lt;/strong&gt; Every abstraction you use daily — &lt;code&gt;malloc&lt;/code&gt;, processes, file I/O — is code someone wrote. Once you write it yourself, you stop taking it for granted.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The CPU is deeply weird.&lt;/strong&gt; Real mode, protected mode, long mode, segment registers, MSRs, the A20 line — x86 has 40 years of backwards compatibility baked in and it shows.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Debugging without tools is humbling.&lt;/strong&gt; No gdb, no printf (at first), no stack traces. Just a serial port, a hex dump, and careful thinking.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Intel manual is your best friend.&lt;/strong&gt; Seriously. Every answer is in there.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What's Next
&lt;/h2&gt;

&lt;p&gt;AxiomX-OS is still a work in progress. Planned next steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[ ] PS/2 Keyboard driver&lt;/li&gt;
&lt;li&gt;[ ] FAT32 filesystem&lt;/li&gt;
&lt;li&gt;[ ] Userspace &amp;amp; syscall interface&lt;/li&gt;
&lt;li&gt;[ ] ELF loader&lt;/li&gt;
&lt;li&gt;[ ] Basic process isolation&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Try It Yourself
&lt;/h2&gt;

&lt;p&gt;The full source code is on GitHub — including all 4 bootloader stages, the kernel, and a Makefile to build and run it in QEMU:&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;&lt;a href="https://github.com/ChairSleeper/AxiomX-OS" rel="noopener noreferrer"&gt;github.com/ChairSleeper/AxiomX-OS&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Requirements: &lt;code&gt;nasm&lt;/code&gt;, &lt;code&gt;gcc&lt;/code&gt; (x86_64-elf cross-compiler), &lt;code&gt;ld&lt;/code&gt;, &lt;code&gt;qemu-system-x86_64&lt;/code&gt;, &lt;code&gt;make&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;make        &lt;span class="c"&gt;# build everything&lt;/span&gt;
make run    &lt;span class="c"&gt;# run in QEMU&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;If this project was useful or interesting to you, consider supporting my open source work:&lt;/p&gt;

&lt;p&gt;💖 &lt;strong&gt;&lt;a href="https://github.com/sponsors/ChairSleeper" rel="noopener noreferrer"&gt;github.com/sponsors/ChairSleeper&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every bit helps me keep building. Thanks for reading!&lt;/p&gt;

</description>
      <category>c</category>
      <category>computerscience</category>
      <category>showdev</category>
      <category>systems</category>
    </item>
    <item>
      <title>Rust vs C: Who is really better?</title>
      <dc:creator>Harsh Thalwal</dc:creator>
      <pubDate>Mon, 10 Nov 2025 10:57:48 +0000</pubDate>
      <link>https://dev.to/harsh_thalwal_d1262cc3a90/rust-vs-c-a-balanced-look-at-performance-safety-and-the-future-of-systems-programming-pp6</link>
      <guid>https://dev.to/harsh_thalwal_d1262cc3a90/rust-vs-c-a-balanced-look-at-performance-safety-and-the-future-of-systems-programming-pp6</guid>
      <description>&lt;p&gt;For decades, &lt;strong&gt;C&lt;/strong&gt; has been the backbone of systems programming — powering everything from operating systems to embedded chips. But in the last few years, a new challenger, &lt;strong&gt;Rust&lt;/strong&gt;, has risen with a bold promise: &lt;em&gt;the performance of C without the memory bugs.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So, in this era of safer and faster programming, the question is — &lt;strong&gt;who wins: Rust or C?&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The Legacy of C
&lt;/h2&gt;

&lt;p&gt;C is the language that built the modern computing world. Created in the 1970s at Bell Labs, it’s behind &lt;strong&gt;UNIX&lt;/strong&gt;, &lt;strong&gt;Linux&lt;/strong&gt;, and most &lt;strong&gt;device firmware&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Developers love C for its &lt;strong&gt;speed, portability, and direct control&lt;/strong&gt; over hardware. You know exactly what the machine is doing, line by line. But that power also comes with danger — memory leaks, segmentation faults, and buffer overflows have haunted C developers for decades.&lt;/p&gt;

&lt;p&gt;Still, C’s simplicity and predictability made it irreplaceable — until Rust arrived.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Rise of Rust
&lt;/h2&gt;

&lt;p&gt;Rust, born at Mozilla in the 2010s, set out to fix what C could not: &lt;strong&gt;memory safety without performance loss.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It introduced a powerful &lt;strong&gt;ownership system&lt;/strong&gt;, where the compiler enforces strict rules about who owns and accesses memory. This prevents common errors like dangling pointers or data races &lt;em&gt;before&lt;/em&gt; your program even runs.&lt;/p&gt;

&lt;p&gt;In short — if your Rust code compiles, it’s probably safe.&lt;/p&gt;

&lt;p&gt;And unlike garbage-collected languages like Java or Python, Rust doesn’t rely on a runtime to manage memory. You get &lt;strong&gt;C-like performance&lt;/strong&gt; with far fewer crashes.&lt;/p&gt;




&lt;h2&gt;
  
  
  Performance and Safety: Head to Head
&lt;/h2&gt;

&lt;p&gt;Both C and Rust compile to machine code, so performance-wise, they’re neck and neck.&lt;/p&gt;

&lt;p&gt;However, Rust takes the edge when it comes to &lt;strong&gt;concurrent programming&lt;/strong&gt; — it makes sure your threads don’t access the same data in unsafe ways. In C, that’s entirely up to you (and your debugging skills).&lt;/p&gt;

&lt;p&gt;Rust’s biggest win is &lt;strong&gt;memory safety&lt;/strong&gt;. Where C demands discipline, Rust enforces it automatically. You spend less time tracking bugs and more time building actual features.&lt;/p&gt;




&lt;h2&gt;
  
  
  Developer Experience
&lt;/h2&gt;

&lt;p&gt;C is minimalist — you can learn it quickly, but mastering it safely takes years. Rust is the opposite: it’s &lt;strong&gt;harder to learn&lt;/strong&gt;, but once you grasp it, it feels empowering.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Rust compiler&lt;/strong&gt; is famously strict but extremely helpful. With tools like &lt;strong&gt;Cargo&lt;/strong&gt; (package manager) and &lt;strong&gt;Clippy&lt;/strong&gt; (linter), writing modern, maintainable code is easier than ever.&lt;/p&gt;

&lt;p&gt;It’s not rare to see developers say, &lt;em&gt;“Rust made me a better programmer.”&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Use Cases and Ecosystem
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;C excels in:&lt;/strong&gt; operating systems, embedded systems, compilers, and hardware-level programming.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rust excels in:&lt;/strong&gt; web servers, game engines, blockchain, and safety-critical systems.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Big names like &lt;strong&gt;Microsoft&lt;/strong&gt;, &lt;strong&gt;Google&lt;/strong&gt;, and &lt;strong&gt;Amazon&lt;/strong&gt; are already integrating Rust into their core infrastructure — often replacing old C/C++ modules for better security and reliability.&lt;/p&gt;

&lt;p&gt;That says a lot about where the industry is heading.&lt;/p&gt;




&lt;h2&gt;
  
  
  Verdict: Not Rivals, but Partners
&lt;/h2&gt;

&lt;p&gt;So, who wins — Rust or C?&lt;/p&gt;

&lt;p&gt;It’s not really a battle. &lt;strong&gt;C&lt;/strong&gt; remains unbeatable for ultra-low-level tasks and legacy systems. But &lt;strong&gt;Rust&lt;/strong&gt; is the natural successor for projects that demand both &lt;strong&gt;speed and safety&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In truth, Rust doesn’t want to replace C — it wants to &lt;strong&gt;evolve&lt;/strong&gt; it.&lt;br&gt;
One built the digital world; the other is making it safer.&lt;/p&gt;




&lt;h3&gt;
  
  
  Final Thoughts
&lt;/h3&gt;

&lt;p&gt;Rust and C aren’t enemies — they’re milestones.&lt;br&gt;
C gave us control; Rust gives us confidence.&lt;/p&gt;

&lt;p&gt;In the end, the best developers aren’t the ones who pick sides. They’re the ones who know &lt;strong&gt;when to use which.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>rustvsc</category>
      <category>rust</category>
      <category>rustmemorysafety</category>
      <category>whichisbetter</category>
    </item>
    <item>
      <title>Beginner friendly Postfix-Prefix tutorial for CLI Calculator in Python.</title>
      <dc:creator>Harsh Thalwal</dc:creator>
      <pubDate>Thu, 23 Jan 2025 18:30:00 +0000</pubDate>
      <link>https://dev.to/harsh_thalwal_d1262cc3a90/beginner-friendly-postfix-prefix-tutorial-for-cli-calculator-in-python-5a38</link>
      <guid>https://dev.to/harsh_thalwal_d1262cc3a90/beginner-friendly-postfix-prefix-tutorial-for-cli-calculator-in-python-5a38</guid>
      <description>&lt;p&gt;Hello everyone!👋&lt;br&gt;
I’m sure you’ve all seen many simple calculator tutorials online—whether on YouTube, other social media, or well you get the idea! There are tons of beginner-friendly calculator tutorials out there, but most are limited to something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Enter n1 : 2
Enter n2 : 3
Enter operator &lt;span class="o"&gt;(&lt;/span&gt;+,-,&lt;span class="k"&gt;*&lt;/span&gt;,/&lt;span class="o"&gt;)&lt;/span&gt; : +
Result : 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As a coder and user, I found this approach a bit tedious. Entering numbers and operators separately feels clunky and restricts you from solving more complex expressions quickly. So, I thought, why not create a simple yet powerful calculator that can handle full mathematical expressions in one go? Something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;Enter&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;23&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;21&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;32&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;34&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;
&lt;span class="n"&gt;Result&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1003.2352941176471&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I won’t say it’s perfect (don’t worry — the answer is correct!), but I really like how it lets me enter full expressions naturally. Plus, it’s a fun challenge to flex my problem-solving skills 😅. In this blog, I’ll share how I built this calculator, the hurdles I faced, and how you can create your own to tackle complex math with ease!&lt;/p&gt;

&lt;p&gt;In this tutorial, I’ll keep things simple. There will still be room for improvement — and that part is up to you!&lt;br&gt;&lt;br&gt;
So, let’s get started! 🚀&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The plan was quite simple.&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Take the user input, which would be an infix expression (something like this :- 2+1-2+32).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Convert it into postfix. Which would look like this : [ 2,1,2,32,+,-,+ ].&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;And then solve it. How? It’s explained later in this blog post.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h1&gt;
  
  
  1. Taking the user input.
&lt;/h1&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;valid_inputs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;0&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;2&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;3&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;4&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;5&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;6&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;7&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;8&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;9&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;+&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;-&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;user_input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Enter : &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;user_input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;user_input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;char&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;user_input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;char&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;valid_inputs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Invalid input&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt;
    &lt;span class="nf"&gt;userinput_to_infix_generator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user_input&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Inside the main() function I did two things.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Taking the user input.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Making sure that it was a valid input.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If there is problem with the expressions like having an invalid symbol the code immediately raises a value error.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;valid_inputs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;0&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;2&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;3&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;4&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;5&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;6&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;7&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;8&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;9&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;+&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;-&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;user_input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Enter : &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;user_input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;user_input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;char&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;user_input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;-----&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;char&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;valid_inputs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Invalid input&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The loop checks each character (&lt;code&gt;char&lt;/code&gt;) from the user's input. If any character isn't in the &lt;code&gt;valid_inputs&lt;/code&gt; list, a &lt;code&gt;ValueError&lt;/code&gt;is raised. If all characters are valid, the code moves on to the next step.&lt;/p&gt;

&lt;p&gt;Once it’s done with comparison and it was a success. It calls the function &lt;code&gt;userinput_to_infix_generator(user_input)&lt;/code&gt; with &lt;code&gt;user_input&lt;/code&gt; as argument.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;userinput_to_infix_generator(user_input)&lt;/code&gt; function takes the clean input and turns it into a list of tokens we can later convert from infix to postfix.&lt;/p&gt;

&lt;p&gt;You're right! Here's your full section rewritten cleanly in &lt;strong&gt;Markdown&lt;/strong&gt;, with everything from your original idea included, and polished for clarity and readability — all ready to be pasted into your blog:&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;userinput_to_infix_generator(user_input)&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;The code itself isn’t very complex — it just turns the &lt;code&gt;user_input&lt;/code&gt; string into a list called &lt;code&gt;infix&lt;/code&gt;, where each number and operator is stored as a separate item.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;userinput_to_infix_generator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user_input&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;infix&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="n"&gt;temp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;""&lt;/span&gt;
    &lt;span class="n"&gt;symbols&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;+&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;-&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;user_input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;-------&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;symbols&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;temp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;temp&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;infix&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;temp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;infix&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;temp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;""&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;temp&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;infix&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;temp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;infix_to_postfix&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;infix&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The key part of this function is how it handles the input when numbers are written together without clear spaces — for example, &lt;code&gt;223+32&lt;/code&gt;. We don't want to treat &lt;code&gt;'2'&lt;/code&gt;, &lt;code&gt;'2'&lt;/code&gt;, and &lt;code&gt;'3'&lt;/code&gt; as separate characters. Instead, we need to combine them into a full number like &lt;code&gt;"223"&lt;/code&gt; and then store it in the list.&lt;/p&gt;

&lt;p&gt;This is handled inside the loop:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If the character is &lt;strong&gt;not&lt;/strong&gt; an operator (&lt;code&gt;+&lt;/code&gt;, &lt;code&gt;-&lt;/code&gt;, &lt;code&gt;*&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt;), it's added to a temporary string &lt;code&gt;temp&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When an operator is found, the function:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. Adds the number stored in `temp` to the `infix` list,

2. Then adds the operator,

3. And resets `temp` for the next number.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Finally, after the loop ends, if &lt;code&gt;temp&lt;/code&gt; still holds the last number, it adds that to the list too.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example:
&lt;/h2&gt;

&lt;p&gt;For input: &lt;code&gt;12+7*5&lt;/code&gt; The resulting &lt;code&gt;infix&lt;/code&gt; list would be: &lt;code&gt;['12', '+', '7', '*', '5']&lt;/code&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  2. Convert it to postfix
&lt;/h1&gt;

&lt;p&gt;Alright, now that we’ve turned our input string into a nice clean list (our &lt;code&gt;infix&lt;/code&gt; expression), the next step is to convert that into postfix format. This part is super important — because computers find postfix (also known as Reverse Polish Notation) much easier to solve than regular infix math.&lt;/p&gt;

&lt;p&gt;At first, I wrote a big if-else mess (you might’ve done that too 😅), but then I realized: why not use a simple approach that handles everything neatly using operator &lt;strong&gt;precedence&lt;/strong&gt;?&lt;/p&gt;

&lt;p&gt;Here’s the final version I settled on:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;infix_to_postfix&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;infix&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;postfix&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="n"&gt;stack&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="n"&gt;precedence&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;+&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;-&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;infix&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;precedence&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;postfix&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;stack&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;precedence&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;precedence&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
                &lt;span class="n"&gt;postfix&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
            &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;postfix&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="nf"&gt;postfix_to_solution&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;postfix&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  But what’s really going on here?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;I created a &lt;code&gt;precedence&lt;/code&gt; dictionary to decide which operators are stronger (&lt;code&gt;*&lt;/code&gt; and &lt;code&gt;/&lt;/code&gt; are stronger than &lt;code&gt;+&lt;/code&gt; and &lt;code&gt;-&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Then, I loop through each token in the infix list:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If it’s a number, it goes straight to the &lt;code&gt;postfix&lt;/code&gt; list.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If it’s an operator, we compare it with the one on top of the stack:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If the stack's operator has &lt;strong&gt;higher or equal precedence&lt;/strong&gt;, we pop it out and add it to &lt;code&gt;postfix&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Otherwise, we just push our current operator onto the stack.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Once we're done looping, we pop any remaining operators from the stack and add them to the result.&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;




&lt;h3&gt;
  
  
  Example Time!
&lt;/h3&gt;

&lt;p&gt;Let’s say the infix expression is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;12&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;+&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;7&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;5&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This function turns it into:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;12&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;7&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;5&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;+&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  3. Solve it
&lt;/h1&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;postfix_to_solution(postfix)&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Alright, we’ve got our expression nicely converted into postfix form. Now it’s time for the grand finale — solving it! This function takes that postfix list and actually &lt;strong&gt;computes the answer&lt;/strong&gt;. Here's the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;postfix_to_solution&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;postfix&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;stack&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;postfix&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isdigit&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
            &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;+&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;-&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Result:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  What’s happening here?
&lt;/h3&gt;

&lt;p&gt;This is a classic &lt;strong&gt;postfix evaluation using a stack&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If the token is a number, we push it onto the stack.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If it’s an operator (&lt;code&gt;+&lt;/code&gt;, &lt;code&gt;-&lt;/code&gt;, &lt;code&gt;*&lt;/code&gt;, or &lt;code&gt;/&lt;/code&gt;), we pop &lt;strong&gt;two numbers&lt;/strong&gt; from the stack:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt;, where &lt;code&gt;a&lt;/code&gt; is the second-last and &lt;code&gt;b&lt;/code&gt; is the last one pushed.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;We perform the operation: &lt;code&gt;a + b&lt;/code&gt;, &lt;code&gt;a - b&lt;/code&gt;, etc., and push the result back onto the stack.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;In the end, if everything went well, the stack will contain &lt;strong&gt;one final value&lt;/strong&gt; — the answer!&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;




&lt;h3&gt;
  
  
  Example:
&lt;/h3&gt;

&lt;p&gt;Say your postfix list is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;12&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;7&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;5&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;+&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's how the evaluation would go:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Push &lt;code&gt;12&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Push &lt;code&gt;7&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Push &lt;code&gt;5&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;See &lt;code&gt;*&lt;/code&gt; → pop &lt;code&gt;5&lt;/code&gt; and &lt;code&gt;7&lt;/code&gt; → push &lt;code&gt;35&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;See &lt;code&gt;+&lt;/code&gt; → pop &lt;code&gt;35&lt;/code&gt; and &lt;code&gt;12&lt;/code&gt; → push &lt;code&gt;47&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Final result: &lt;code&gt;47&lt;/code&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Quick Note
&lt;/h3&gt;

&lt;h3&gt;
  
  
  This code uses &lt;code&gt;int()&lt;/code&gt; to convert digits, so it won’t work with decimal numbers like &lt;code&gt;2.5&lt;/code&gt; yet. If you want to support floats, just change &lt;code&gt;int(token)&lt;/code&gt; to &lt;code&gt;float(token)&lt;/code&gt; — easy fix!
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;And that’s it…, now ask yourself.&lt;br&gt;&lt;br&gt;
“Is there any room of improvement?”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Yes! A lot!.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;There’s also one major issue with this calculator. Try giving it an input like&lt;/strong&gt; &lt;code&gt;2++3-2&lt;/code&gt; &lt;strong&gt;— yeah, it breaks! 😅 It doesn’t currently handle invalid operator sequences properly. I’m leaving this part on you to fix.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;There are a lot of other things you can do with this, maybe try adding brackets support?.&lt;/strong&gt;
&lt;/h2&gt;

&lt;h2&gt;
  
  
  🎯 Wrapping it up
&lt;/h2&gt;

&lt;p&gt;This calculator may be simple, but building it helped me understand how real interpreters work behind the scenes. From reading input, validating it, converting between notations, and finally evaluating — it’s all there.&lt;/p&gt;

&lt;p&gt;There’s still room for improvements — like handling decimals, parentheses, or even making a GUI. But I’ll leave that challenge to you!&lt;/p&gt;

&lt;p&gt;Thanks for reading 😄&lt;br&gt;&lt;br&gt;
Let me know in the comments what you added or improved!&lt;/p&gt;

</description>
      <category>programming</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>python</category>
    </item>
  </channel>
</rss>
