Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. def push_or_pop(alist):
  2.     new_list = []
  3.     for lists in alist:
  4.         if type(lists) == int:
  5.             if lists > 5:
  6.                 new_list.append(lists)
  7.  
  8.             elif lists <= 5:
  9.                 new_list.pop(-1)
  10.  
  11.             else:
  12.                 print("invalid number")
  13.     return new_list
  14.  
  15.  
  16. print(push_or_pop([12, 10, 4, 8, 3, 9]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement