练习3.实现栈的入栈出栈等功能
#!/usr/bin/env python
#coding:utf-8
__author__ = "hahaha"
'''
@author:hahaha
@file:haha.py
@contact:769218703@qq.com
@time:7/01/10:18 AM
@desc:
'''
stack = []
def pushstack():
item = raw_input("newitem:")
stack.append(item)
def popstack():
if len(stack) == 0:
print "can not popfrom empty stack."
else:
print "%s pop fromstack" % stack.pop()
def viewstack():
print stack
def showmenu():
str = 'welcome to stackmanage'
列表练习
最新推荐文章于 2020-08-27 19:02:22 发布