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?

I have a question regarding python and passing data. I understand that

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!