OsahonE

Wk4_3

Mar 31st, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. '''A program that returns the first-two
  2. elements of a list, if the second argument
  3. is an odd number and returns from the
  4. third element to the last element if the
  5. second argument is an even number'''
  6.  
  7. def split_in_two(list, num: int):
  8.     if num % 2 == 0:
  9.         return list[2:]
  10.     else:
  11.         return list[0:2]
  12.        
  13. print(split_in_two(["food", "music", "game", "sleep", "book"], 4))
  14. print(split_in_two(["food", "music", "game", "sleep", "book"], 3))
Advertisement
Add Comment
Please, Sign In to add comment