Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''A program that returns the first-two
- elements of a list, if the second argument
- is an odd number and returns from the
- third element to the last element if the
- second argument is an even number'''
- def split_in_two(list, num: int):
- if num % 2 == 0:
- return list[2:]
- else:
- return list[0:2]
- print(split_in_two(["food", "music", "game", "sleep", "book"], 4))
- print(split_in_two(["food", "music", "game", "sleep", "book"], 3))
Advertisement
Add Comment
Please, Sign In to add comment