Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import funcs
- r=[]
- def add(a):
- r.append(a)
- return 'Successfully added '+a
- def remove():
- if(len(r)>0):
- r.pop()
- return 'successfully POP'
- else:
- return "operation was not SuccessFul. this is Empty!!"
- def size():
- return len(r)
- def pick():
- return r[-1]
- def show():
- return r
- function_dict = {'add':add, 'remove':remove,'show':show,'pick':pick,'size':size}
- funcs1=['add','remove','size','pick','show','quit']
- var=1
- #print(funcs1)
- firstval=input('please type what you wanna do?')
- while(var==1):
- if(firstval[0:3]=='add'):
- try:
- f=firstval.index(' ')
- valuee= firstval[f+1:]
- commandd=firstval[0:f]
- except:
- print("Your command is not Correct!!! ")
- else:
- commandd=firstval
- if (commandd in funcs1):
- if(commandd=='add'):
- # function_dict[commandd](valuee)
- print(function_dict[commandd](valuee))
- else:
- # function_dict[commandd]()
- print(function_dict[commandd]())
- # print(commandd())
- else:
- print("an error has occured the command "+commandd+" is not available")
- firstval = input('please type what you wanna do?')
- if(firstval=='quit'):
- var=0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement