Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def every_third(original_list):
- """(list) -> (list)
- Takes the original_list list and returns a new list consisting of every
- third element in the original_list. Function will use a while loop.
- >>>every_third([10, 5, 8, 12, 4, 16])
- [8, 16]
- """
- new_list = []
- counter = 0
- while counter <= len(original_list):
- if (original_list[counter + 1] % 3) == 0:
- new_list.append(original_list[counter])
- counter = counter + 1
- return new_list
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement