Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This is a split_in_two function that accepts a list and a numrber.
- # if number is even, it returns the list elements from the third element to the end.
- # if the number is odd, it returns the list elements from index 0 to 2
- def split_in_two(anylist, number):
- if number % 2 == 0:
- print(anylist[3:])
- else:
- print(anylist[:2])
- split_in_two(["fish", "dogs", "chemistry", "pentane", "magic", "absolute value"]
- , 2)
- split_in_two(["fish", "dogs", "chemistry", "pentane", "magic", "absolute value"]
- , 1)
- split_in_two(["fish", "dogs", "chemistry", "pentane", "magic", "absolute value"]
- , 15)
- split_in_two(["fish", "dogs", "chemistry", "pentane", "magic", "absolute value"]
- , 6)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement