From the course: Programming Foundations: Real-World Examples

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Stacks

Stacks - Python Tutorial

From the course: Programming Foundations: Real-World Examples

Start my 1-month free trial

Stacks

- While I was outside I grabbed the mail, and unfortunately, it looks like today is nothing but bills and junk mail. As I sorted through my mail, when I come across a bill, I'll put it on a stack to be processed. And, as for the junk mail, I'll just toss that. So this first item is a bill, I'll place it on my stack. The next item is also a bill, so I'll place it into the stack on top of that first one. Junk mail, junk mail. Another bill, that goes on the stack. Junk mail, and a bill. Now, the bills on my stack are ordered from top to bottom with the most recent bill I put onto the stack at the top, and the oldest bill at the bottom. When I'm ready to begin paying these bills, I'll grab the last envelope that I put onto the stack, which is at the top, and I'll start working my way down the stack paying my bills in the opposite order that I put them onto the stack. - Hey, it looks like you dropped a bill on the way in. - Whoops! Well, I'll just put that here on top of the stack. Since…

Contents