Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """The function splits a list argument into depending on whether
- a number supplied is even or odd"""
- def split_in_two(value, number):
- if number % 2 == 0: # Even Condition
- return value[2:]
- else: # Odd Condition
- return value[:2]
- print(split_in_two(["a", "b", "c", "d", "e", "f"], 3)) # ['a', 'b']
- print(split_in_two(["a", "b", "c", "d", "e", "f"], 4)) # ['c', 'd', 'e', 'f']
- print(split_in_two(["a", "b", "c", "d", "e", "f"], 1)) # ['a', 'b']
- print(split_in_two(["a", "b", "c", "d", "e", "f"], 10)) # ['c', 'd', 'e', 'f']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement