Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. import funcs
  2. r=[]
  3. def add(a):
  4. r.append(a)
  5. return 'Successfully added '+a
  6. def remove():
  7. if(len(r)>0):
  8. r.pop()
  9. return 'successfully POP'
  10. else:
  11. return "operation was not SuccessFul. this is Empty!!"
  12. def size():
  13. return len(r)
  14. def pick():
  15. return r[-1]
  16. def show():
  17. return r
  18. function_dict = {'add':add, 'remove':remove,'show':show,'pick':pick,'size':size}
  19. funcs1=['add','remove','size','pick','show','quit']
  20. var=1
  21. #print(funcs1)
  22. firstval=input('please type what you wanna do?')
  23. while(var==1):
  24. if(firstval[0:3]=='add'):
  25. try:
  26. f=firstval.index(' ')
  27. valuee= firstval[f+1:]
  28. commandd=firstval[0:f]
  29. except:
  30. print("Your command is not Correct!!! ")
  31. else:
  32. commandd=firstval
  33. if (commandd in funcs1):
  34. if(commandd=='add'):
  35. # function_dict[commandd](valuee)
  36. print(function_dict[commandd](valuee))
  37. else:
  38. # function_dict[commandd]()
  39. print(function_dict[commandd]())
  40.  
  41. # print(commandd())
  42. else:
  43. print("an error has occured the command "+commandd+" is not available")
  44. firstval = input('please type what you wanna do?')
  45. if(firstval=='quit'):
  46. var=0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement