Split in two

ganiyuisholaafeez Feb 22nd, 2020 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. """The function splits a list argument into depending on whether
  2. a number supplied is even or odd"""
  3. def split_in_two(value, number):
  4.     if number % 2 == 0: # Even Condition
  5.         return value[2:]
  6.     else:               # Odd Condition
  7.         return value[:2]
  9. print(split_in_two(["a", "b", "c", "d", "e", "f"], 3)) # ['a', 'b']
  10. print(split_in_two(["a", "b", "c", "d", "e", "f"], 4)) # ['c', 'd', 'e', 'f']
  11. print(split_in_two(["a", "b", "c", "d", "e", "f"], 1)) # ['a', 'b']
  12. print(split_in_two(["a", "b", "c", "d", "e", "f"], 10)) # ['c', 'd', 'e', 'f']
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