Skip to content

Instantly share code, notes, and snippets.

@shashisp
Created August 29, 2015 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shashisp/ff696ac16b96c55bbde6 to your computer and use it in GitHub Desktop.
Save shashisp/ff696ac16b96c55bbde6 to your computer and use it in GitHub Desktop.
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