Blessing988

Untitled

Feb 21st, 2020
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. def push_or_pop(list_of_numbers):
  2.     new_list = [ ]
  3.     for number in list_of_numbers:
  4.         if number > 5:
  5.             new_list.append(number)
  6.         else:
  7.             new_list.pop( )
  8.     print(new_list)
  9.  
  10.  
  11. push_or_pop([10, 20, 2, 30])  #Example (argument should consist of a list of numbers)
Advertisement
Add Comment
Please, Sign In to add comment