Question
I have a question regarding python and passing data. I understand that myStack.push(somevalue) will push itself and somevalue. That is, it's passes 2 arguments. foo
I have a question regarding python and passing data.
I understand that myStack.push(somevalue) will push itself and somevalue. That is, it's passes 2 arguments.
foo = function that returns a tuple with 3 values (somevalue1, somevalue 2, somevalue3)
I tried myStack.push([foo]) because I wanted to start a list with the return values from foo, but the interpreter said that is only 1 argument.
I then tried mystack.push(foo, [ ]) but then it said that is 3 arguments
I want to know what is going on with this call: myStack.push((foo , [ ] )) and why that works as 2 arguments. Am I really pushing the values onto myStack as a list or is it doing something I am not understanding?
class Stack: "A container with a last-in-first-out (LIFO) queuing policy." def _init__(self): self.list = [] | def push(self, item): "Push 'item' onto the stack" self.list.append(item) def pop (self): "Pop the most recently pushed item from the stack" return self.list.pop() def isEmpty (self): "Returns true if the stack is empty" return len(self.list) == 0
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started