forked from nsshayan/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMonkLoveForFood.py
44 lines (34 loc) · 915 Bytes
/
MonkLoveForFood.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 08 10:03:28 2016
@author: snaganan
"""
class stack:
def __init__(self):
self.stackData = []
def push(self,data):
self.stackData.insert(0,data)
def pop(self):
popData = self.stackData[0]
del self.stackData[0]
return popData
def topElement(self):
return self.stackData[0]
def isEmpty(self):
if len(self.stackData) == 0 :
return True
else :
return False
def size(self):
return len(self.stackData)
Q = int(raw_input())
FoodStack = stack()
for i in range(Q):
testCase = raw_input()
if testCase == '1':
if FoodStack.isEmpty():
print 'No Food'
else :
print FoodStack.pop()
else:
FoodStack.push(testCase.split(' ')[1])