SHARE
TWEET

Untitled

a guest Feb 21st, 2020 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # This is a split_in_two function that accepts a list and a numrber.
  2. # if number is even, it returns the list elements from the third  element to the end.
  3. # if the number is odd, it returns the list elements from index 0 to 2
  4.  
  5. def split_in_two(anylist, number):
  6.     if number % 2 == 0:
  7.         print(anylist[3:])
  8.     else:
  9.        
  10.         print(anylist[:2])
  11.        
  12. split_in_two(["fish", "dogs", "chemistry", "pentane", "magic", "absolute value"]
  13. , 2)
  14. split_in_two(["fish", "dogs", "chemistry", "pentane", "magic", "absolute value"]
  15. , 1)
  16. split_in_two(["fish", "dogs", "chemistry", "pentane", "magic", "absolute value"]
  17. , 15)
  18. split_in_two(["fish", "dogs", "chemistry", "pentane", "magic", "absolute value"]
  19. , 6)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top