Created
August 29, 2015 17:38
-
-
Save shashisp/ff696ac16b96c55bbde6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = int(raw_input()) | |
stack = [] | |
def push(element): | |
stack.append(element) | |
return element | |
def pop(): | |
if len(stack) == 0: | |
print "EMPTY" | |
return 0 | |
else: | |
return stack.pop() | |
def inc(count, inc_by): | |
if len(stack) == 0: | |
print "EMPTY" | |
return 0 | |
for k in range(0, count): | |
stack[k] = stack[k] + inc_by | |
return 0 | |
for i in range(n): | |
x = raw_input() | |
if x == 'push': | |
print "enter an element to push" | |
e = int(raw_input()) | |
push(e) | |
if x == 'pop': | |
pop() | |
if x == 'inc': | |
print "Enter the no.of elements to be incremented and by how much with (eg: 1 4)" | |
count, inc_by = raw_input().split() | |
count = int(count) | |
inc_by = int(inc_by) | |
inc(count, inc_by) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment