We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Your code at http://tinyurl.com/jj7d7nx2 for Challenge 2 in Chapter 21 returns:
[1, 2, 3, 4, 5,]
The challenge was to "create a new list with the items in the following list reversed: [1, 2, 3, 4, 5].
FWIW, this is the code that I used to solve the challenge:
class Stack: def __init__(self): self.items = [] def is_empty(self): return self.items == [] def push(self, item): self.items.append(item) def pop(self): return self.items.pop() def peek(self): last = len(self.items)-1 return self.items[last] def size(self): return len(self.items) stack = Stack() int_list = [] for c in range(1, 6): stack.push(c) reverse = [] for i in range(len(stack.items)): reverse.append(stack.pop()) print(reverse)
[5, 4, 3, 2, 1]
The text was updated successfully, but these errors were encountered:
@ILeftTheLaw You are completely correct. I just fixed it. Thanks so much for pointing this out. I should have you be the editor of my next book :).
Sorry, something went wrong.
No branches or pull requests
Your code at http://tinyurl.com/jj7d7nx2 for Challenge 2 in Chapter 21 returns:
[1, 2, 3, 4, 5,]
The challenge was to "create a new list with the items in the following list reversed: [1, 2, 3, 4, 5].
FWIW, this is the code that I used to solve the challenge:
The text was updated successfully, but these errors were encountered: